【问题标题】:Cucumber, how to write this line黄瓜,这行怎么写
【发布时间】:2018-05-04 03:22:12
【问题描述】:

我做了一些 selenium-webdriver ruby​​ 代码。它可以工作,但现在我想使用 cucumber 来利用绿色和红色看起来不错的 html 报告。当我开始在名为 custom_steps.rb 的文件中使用一些代码时,它不起作用。

  1. 你能告诉我如何在这个文件中写下这一行吗:

    require 'selenium-cucumber'
    
    # Do Not Remove This File
    # Add your custom steps here
    # $driver is instance of webdriver use this instance to write your custom code
    
    divs = $driver.find_elements(:xpath,"//div[@class='col-xs-12 check-box-container']/a/div");
    
  2. custom_steps.rb 中的代码如何在.feature 文件中调用?

【问题讨论】:

    标签: ruby selenium cucumber


    【解决方案1】:

    该文件没有调用它,您的步骤定义解释了 .feature 文件中的含义。

    在您的步骤定义文件中,您需要编写正则表达式以匹配.feature 文件中的行。

    这里是 dispora 的一个实际语法示例,这是一个大型的 Rails 应用程序,包含许多黄瓜测试 https://github.com/diaspora/diaspora/blob/21980681b156bc163c616cf0344bcdf3f3a195db/features/step_definitions/search_steps.rb

    另见https://github.com/cucumber/cucumber-ruby

    【讨论】:

    • 谢谢,dispora 网站很有帮助。
    • 是否有任何网站运行散居。所以我可以使用这些测试来练习?谢谢,
    • 在他们的网站 diasporafoundation.org 的某个地方,该代码正在运行,但我不确定您使用这种方法会有多少运气,因为他们的测试设置看起来相当复杂。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-23
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    • 2012-03-10
    • 2020-06-04
    相关资源
    最近更新 更多