如何使用Cucumber.js检查损坏的链接

时间:2016-05-12 14:57:16

标签: javascript webdriver-io cucumberjs chimp.js

我需要使用Cucumber.js检查404页面上的链接。所以我猜两件事。

  • 如何在场景中实现循环。因为用户应该点击链接并多次返回页面

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

  • 第二个是如何在js文件中点击所有链接检查内容并在每次检查后返回主页面。

2 个答案:

答案 0 :(得分:0)

您应该考虑使用Mocha进行此类测试,Gherkin不适用于循环等。有关详细信息,请参阅此答案:

Step definitions library for Meteor-cucumber/chimp

答案 1 :(得分:0)

您可以使用场景轮廓并将网址传递为变量

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   |