Ruby Watir Webdriver - 如何识别和点击 div 标签中的元素?
Ruby Watir Webdriver - How to identify and click on the element in div tag?
**我试图从网页中识别 div 元素并使用 watir 点击它 **
页数:
<div class="account-buttons">
<a href="/account/register" class="signup1 action-button">Sign Up with Email</a>
<a href="/account/login" class="login1 action-button">Have an account? Log In</a>
</div>
Watir 代码:
Then(/^I signup with email$/) do
browser.button(text: "Sign Up with Email").wait_until_present.click
end
Then(/^I click on button with text "([^"]*)" in div identifier "([^"]*)"$/) do |arg1, arg2|
browser.buttons(:text, arg1).divs(:class, arg2).click
end
异常:
timed out after 30 seconds, waiting for true condition on #<Watir::Button: located: false; {:text=>"Sign Up with Email", :tag_name=>"button"}> (Watir::Wait::TimeoutError)
./Features/Step_definitions/ChefD.rb:73:in `/^I signup with email$/'
features/Sanity_scenarios.feature:8:in `Then I signup with email'
请问如何处理?
它在 link 里面,div 是那个 link 的父级,
所以写这段代码
b.element(link: 'Sign Up with Email').click
或
b.link(text: 'Sign Up with Email').click
它会起作用。
**我试图从网页中识别 div 元素并使用 watir 点击它 **
页数:
<div class="account-buttons">
<a href="/account/register" class="signup1 action-button">Sign Up with Email</a>
<a href="/account/login" class="login1 action-button">Have an account? Log In</a>
</div>
Watir 代码:
Then(/^I signup with email$/) do
browser.button(text: "Sign Up with Email").wait_until_present.click
end
Then(/^I click on button with text "([^"]*)" in div identifier "([^"]*)"$/) do |arg1, arg2|
browser.buttons(:text, arg1).divs(:class, arg2).click
end
异常:
timed out after 30 seconds, waiting for true condition on #<Watir::Button: located: false; {:text=>"Sign Up with Email", :tag_name=>"button"}> (Watir::Wait::TimeoutError)
./Features/Step_definitions/ChefD.rb:73:in `/^I signup with email$/'
features/Sanity_scenarios.feature:8:in `Then I signup with email'
请问如何处理?
它在 link 里面,div 是那个 link 的父级,
所以写这段代码
b.element(link: 'Sign Up with Email').click
或
b.link(text: 'Sign Up with Email').click
它会起作用。