Selenium :: WebDriver :: Error ::使用Watir循环到单击按钮时的ElementNotVisibleError

时间:2014-09-27 12:46:54

标签: ruby rspec watir watir-webdriver

我试图在循环的基础上点击一个按钮。

我们说我有以下代码

if ind == 2
  export_id = @browser.div(:id => pop_id).div(:class => /actionDropDownItem groupChild nonSelectable/,:title => "Export").id
  @browser.div(:id => export_id).click
else
  @browser.div(:id => pop_id).div(:class => /actionDropDownItem groupChild nonSelectable/,:title => "Export").click
end

但它在索引值“2”处显示错误,错误为

Selenium::WebDriver::Error::ElementNotVisibleError:
Element is not currently visible and so may not be interacted with

在这种情况下,有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

如果您提供适当的HTML,那就太棒了。

尝试一次,这对你有用

if ind == 2
  export_id = @browser.div(:id => export_id)
  export_id.click
else
  @browser.div(:id => pop_id).div(:class => /actionDropDownItem groupChild nonSelectable/,:title => "Export").click
end