DEV Community

Discussion on: Cucumber.js Tutorial with Examples For Selenium JavaScript

Collapse
 
adamdsherman profile image
AdamDSherman

Great tutorial!

I have one issue that's been bugging me for ages. That is, running the same test on multiple pages.

For example, if I want to check that 2 different pages have a banner element on them:

On home-page.feature

Feature: Home Page

Scenario: Check the home page
    Given I am on the home page
    Then there should be a banner
    // other test
Enter fullscreen mode Exit fullscreen mode

and on about-page.feature

Feature: About Page

Scenario: Check the about page
    Given I am on the about page
    Then there should be a banner
    // other test
Enter fullscreen mode Exit fullscreen mode

and then on each matching steps.js I have:

Then('there should be a banner', async function() {....
Enter fullscreen mode Exit fullscreen mode

Which fails with the error: Multiple step definitions match

Do you know of a way I can run the same test on multiple pages?

Many thanks!