0

I need to check links on page for 404 using Cucumber.js. So I am guessing out on two things.

  • How to implement loop in scenario. Because user should click on links and return back to page multiple times

Feature: Check broken links

Scenario: User clicks on links on web page Given User is on website And he clicks on link Then he shouldn't see 404 And user returns back to click to another link on page

  • And second is how to implement in js file clicking on all links to check content and returning to main page after every check.
romansh
  • 33
  • 4

2 Answers2

0

You should consider using Mocha for this sort of tests, Gherkin is not designed for loops etc. See this answer for more details:

Step definitions library for Meteor-cucumber/chimp

Community
  • 1
  • 1
Xolv.io
  • 2,373
  • 1
  • 12
  • 17
0

You could use scenario outlines and pass in the url as the variable

Feature: Check broken links

Scenario Outline: User clicks on links on web page
    Given User is on website
    And he clicks on <link>
    Then he shouldn't see 404
    And user returns back to click to another link on page

Examples:
  | link |
  |  http://www.google.com   |
  |  http://www.gmail.com   |
findlayc
  • 126
  • 5
  • 1
    technically this works, but it's still not how Cucumber should be used. See more about this from the original Cucumber author: https://cucumber.io/blog/2015/03/24/single-source-of-truth – Xolv.io May 20 '16 at 13:37
  • I agree with the whole "Are you doing BDD? Or are you just using Cucumber?" point of view. Unfortunately our tech choice isn't always up to us – findlayc May 20 '16 at 15:55