question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document how to run same test on multiple urls

See original GitHub issue
viewports = ['mobile', 'tablet', 'desktop']

it ...loop through viewports to create title of test
  cy.viewport(i)
  assertions here

Track down where this has been done successfully in cypress issues

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

28reactions
jennifer-shehanecommented, Apr 18, 2018
const urls = ['https://docs.cypress.io', 'https://www.cypress.io']

describe('Logo', () => {
  urls.forEach((url) => {
    it(`Should display logo on ${url}`, () => {
      cy.visit(url)
      cy.get('#logo img')
        .should('have.attr', 'src')
        .and('include', 'logo')
    })
  })
})
1reaction
melibe23commented, Jan 6, 2020

I tried to do this using beforeEach, but I couldn’t get it going… it was using the last value in my viewport array. I’m sure this is a closure issue, but I couldn’t get it working. Can you post the above example (#521 (comment)) using beforeEach?

I am not using beforeEach, and still, get the same error.

This is my code:

const urls = [
  "https://www.getapp.com/hr-employee-management-software/a/findmyshift/compare/",
  "https://www.getapp.com/hr-employee-management-software/a/findmyshift/compare/quinyx/",
  "https://www.getapp.comhr-employee-management-software/a/findmyshift/compare/quinyx-vs-cakehr/,
  "https://www.getapp.com/hr-employee-management-software/a/findmyshift/compare/quinyx-vs-cakehr-vs-lanteria-hr/"
];

describe("Compare page - Side nav", () => {
  urls.forEach(url => {
    it(`Sidenav is present on ${url}`, () => {
      cy.visit(url);
      cy.xpath('//*[@id="__next"]/div/div/div[1]/div/div/nav').should(
        "be.visible"
      );
    });

  after(() => {
  cy.end();
   });

It only takes into account the last URL in the array.

What I am doing wrong?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run same test for different URLs in Cypress
Way 1 is: loop on each test - so each test will run for 2 URLs and URL I am passing as argument....
Read more >
How can I run the same test case for different URLs? - Archive
I would show you how to run a Katalon Studio project for multiple URLs. First, you create a GlobalVariable named 'Hostname' in the...
Read more >
How to run same test case of testng on 100 different URL ...
1) Store your urls, and test data somewhere (like xml, text file, excel or in other class).
Read more >
Test Multiple Sites with a Single Command - YouTube
In this WebdriverIO Automated Testing Tutorial, we will be learning how to run the same set of tests against multiple URLs.
Read more >
Solved: How to run Keyword tests in different urls.
Use the Call Object Method test action to call the ToURL method on the Sys.Browser() object, passing in the URL variable to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found