Ruby Watir Webdriver-如何识别并单击div标记中的元素?

Ruby Watir Webdriver-如何识别并单击div标记中的元素?,ruby,selenium-chromedriver,watir,watir-webdriver,Ruby,Selenium Chromedriver,Watir,Watir Webdriver,**我试图从网页中识别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 ac

**我试图从网页中识别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>
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'
例外情况:

<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>
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'
30秒后超时,等待#“使用电子邮件注册”,:tag#u name=>“button”}>(Watir::Wait::TimeoutError)上的真实条件
./Features/Step_definitions/ChefD.rb:73:in`/^I使用电子邮件$/'注册
功能/健全场景。功能:8:在“然后我用电子邮件注册”

请帮助我如何处理此问题?

它位于链接内部,div是该链接的父级

所以写下这段代码

b.element(link: 'Sign Up with Email').click


这是可行的。

Welcome@Vinothpandian你可以和cucumber google小组聊一聊原因,但是“然后(/^I单击按钮,在div标识符中使用文本“([^”]*)”([^”]*)“$/)do | arg1,arg2 |”等“通用步骤”是一种黄瓜味。该步骤在具体实现中陷入困境,无法很好地表达正在发生的事情。强烈建议购买并阅读“黄瓜书”