【问题标题】:How to check broken links with Cucumber.js如何使用 Cucumber.js 检查损坏的链接
【发布时间】:2016-05-12 14:57:16
【问题描述】:

我需要使用 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文件中实现点击所有链接查看内容并在每次查看后返回主页面。

【问题讨论】:

    标签: javascript webdriver-io cucumberjs chimp.js


    【解决方案1】:

    您应该考虑使用 Mocha 进行此类测试,Gherkin 不是为循环等设计的。有关更多详细信息,请参阅此答案:

    Step definitions library for Meteor-cucumber/chimp

    【讨论】:

      【解决方案2】:

      您可以使用场景大纲并将 url 作为变量传递

      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   |
      

      【讨论】:

      • 从技术上讲这是可行的,但仍然不是 Cucumber 的使用方式。从 Cucumber 原作者那里了解更多信息:cucumber.io/blog/2015/03/24/single-source-of-truth
      • 我同意整个“你是在做 BDD?还是你只是在使用 Cucumber?”观点看法。不幸的是,我们的技术选择并不总是取决于我们
      猜你喜欢
      • 2011-08-26
      • 1970-01-01
      • 1970-01-01
      • 2012-05-12
      • 2010-12-08
      • 1970-01-01
      • 2014-04-10
      • 2016-01-25
      相关资源
      最近更新 更多