**我尝试从网页识别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 CODE:
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'
请帮我解决这个问题?
答案 0 :(得分:2)
它位于链接内部,div是该链接的父级,
所以写下这段代码
b.element(link: 'Sign Up with Email').click
或者
b.link(text: 'Sign Up with Email').click
它会起作用。