无法识别Ruby-WATIR中的元素?

时间:2017-05-15 15:49:47

标签: ruby cucumber selenium-chromedriver watir

PAGE:

<input type="submit" class="btn auth-button" value="Submit">

WATIR代码:

Then(/^I click on submit$/) do
  browser.button(:class,"btn auth-button").click
end

例外:

Then I click on submit                                                                                   # Features/Step_definitions/ChefD.rb:178
      element located, but timed out after 30 seconds, waiting for true condition on #<Watir::Button: located: true; {:class=>"btn auth-button", :tag_name=>"button"}> (Watir::Exception::UnknownObjectException)
      ./Features/Step_definitions/ChefD.rb:179:in `/^I click on submit$/'
      features/Sanity_scenarios.feature:47:in `Then I click on submit'

帮助我如何识别这个元素?

1 个答案:

答案 0 :(得分:0)

试试这个:

 btn = @browser.button value: 'Submit'
    btn.exists?
    btn.click