简体   繁体   中英

Selenium::WebDriver::Error::ElementNotVisibleError while looping to click button using Watir

I am trying to click a button on loop basis.

Let us say I have following code

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

But it shows error at index value "2" and the Error is

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

Can anyone help me in this case?

It would be great if you provide proper html .

Try this once , this would work for you

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM