Ruby 无法使用此选项运行自定义步骤
我正在使用 . 我的测试包括预定义步骤和自定义步骤 但是,由于自定义步骤导致的错误,我的测试无法运行 我运行的功能文件:Ruby 无法使用此选项运行自定义步骤,ruby,selenium,selenium-webdriver,cucumber,automated-tests,Ruby,Selenium,Selenium Webdriver,Cucumber,Automated Tests,我正在使用 . 我的测试包括预定义步骤和自定义步骤 但是,由于自定义步骤导致的错误,我的测试无法运行 我运行的功能文件: Feature: Login a customer Scenario: Go in a call Given I navigate to <url> ... When I submit the form with id "custSearchSimple" ....
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
当我通过运行\u file.feature的cucumber features/name\u来运行功能文件时,我得到了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)
当我提交id为“custSearchSimple”的表单时#features/step_definitions/custom_steps.rb:12
为#(NoMethodError)调用的私有方法“submit”
我找不到任何使用Selenium Cumber Ruby API编写自定义步骤的示例。我怀疑我可能遗漏了SeleniumWeb驱动程序ruby的一些命令。我找不到的东西不见了。有人知道我为什么会出现这个错误吗?也许我在这里感到困惑,但是:
When(/^I submit the form with id "(.*?)"$/) do |arg1|
submit_form arg1
end
def submit_form(form_id)
submit("id", form_id)
end
你愿意做什么
submit\u form
不是cucumber步骤,而是ruby方法-可能是您获得cucumber::UndefinedDynamicStep
的原因,可能我在这里感到困惑,但:
When(/^I submit the form with id "(.*?)"$/) do |arg1|
submit_form arg1
end
def submit_form(form_id)
submit("id", form_id)
end
你愿意做什么
submit\u form
不是cucumber步骤,它是一个ruby方法-可能是您获得cucumber::UndefinedDynamicStep
的原因是,确实submit是一个ruby函数。抱歉,我最近意识到应该使用SeleniumWebDriver来调用SubmitRuby函数。我刚刚更新了我的帖子。现在,我得到了NoMethodError错误。您试图在浏览器对象上调用submit
,而不是在表单上调用/Selenium::WebDriver::Element
。您需要首先通过执行类似于form=driver.find\u元素(id:form\u id)
的操作来查找表单,然后执行form.submit
。看看这是否有帮助。是的,提交确实是一个ruby函数。抱歉,我最近意识到应该使用SeleniumWebDriver来调用SubmitRuby函数。我刚刚更新了我的帖子。现在,我得到了NoMethodError错误。您试图在浏览器对象上调用submit
,而不是在表单上调用/Selenium::WebDriver::Element
。您需要首先通过执行类似于form=driver.find\u元素(id:form\u id)
的操作来查找表单,然后执行form.submit
。看看这是否有帮助。