【发布时间】:2016-01-16 07:28:27
【问题描述】:
我正在使用 selenium cucumber ruby。 我的测试包括预定义和自定义步骤。
但是,由于自定义步骤导致的错误,我的测试无法运行。
我运行的功能文件:
Feature: Login a customer
Scenario: Go in a call
Given I navigate to <url>
...
When I submit the form with id "custSearchSimple"
....
And I wait for 5 sec
Then element having id "accNumber" should be present
当我提交 id 为“custSearchSimple”的表单时是一个自定义步骤。 此步骤在 custom_step.rb 中定义。我使用了Selenium Cucumber Ruby API 的提交命令。 custom_step.rb 是以下文件:
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
#firefox browser instantiation
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "https://localhost/telebet"
When(/^I submit the form with id "(.*?)"$/) do |arg1|
element= driver.submit(:id,"#{arg1}")
end
当我通过运行 cucumber features/name_of_the_file.feature 运行功能文件时,我收到 NoMethodError 错误:
When I submit the form with id "custSearchSimple" # features/step_definitions/custom_steps.rb:12
private method `submit' called for #<Selenium::WebDriver::Driver:0x94c4bde4bdff4d6 browser=:firefox> (NoMethodError)
我找不到任何使用 Selenium Cucumber Ruby API 编写自定义步骤的示例。我怀疑我可能省略了一些 selenium web 驱动程序 ruby 的命令。缺少一些我找不到的东西。有谁知道我为什么会收到这个错误?
【问题讨论】:
标签: ruby selenium selenium-webdriver cucumber automated-tests