not able to click on button that is visible.

Skip to first unread message

Suresh Murthy

Feb 5, 2021, 11:28:36 PM2/5/21
to Watir General
as you can see from the code, the button exists with text "OK". But i cannot click on it. how do fix this ?
irb(main):189:0> ie.button(value:"OK").html
=> "<input type=\"button\" onclick=\"javascript:makeList('1591993');\" value=\"OK\">"
irb(main):190:0> ie.button(value:"OK").exists?
=> true
irb(main):191:0> ie.button(value:"OK").click

2021-02-05 18:07:41 WARN Selenium [DEPRECATION] Selenium::WebDriver::Error::ElementNotVisibleError is deprecated. Use Selenium::WebDriver::Error::ElementNotInteractableError (ensure the driver supports W3C WebDriver specification) instead.
Traceback (most recent call last):
        8: from C:/Ruby26-x64/bin/irb.cmd:31:in `<main>'
        7: from C:/Ruby26-x64/bin/irb.cmd:31:in `load'
        6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        5: from (irb):191
        4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/watir-6.16.5/lib/watir/elements/element.rb:145:in `click'
        3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/watir-6.16.5/lib/watir/elements/element.rb:790:in `element_call'
        2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/watir-6.16.5/lib/watir/elements/element.rb:803:in `rescue in element_call'
        1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/watir-6.16.5/lib/watir/elements/element.rb:752:in `raise_present'
Watir::Exception::UnknownObjectException (element located, but timed out after 30 seconds, waiting for #<Watir::Button: located: true; {:value=>"OK", :tag_name=>"button"}> to be present)

John Fitisoff

Feb 6, 2021, 12:07:03 AM2/6/21
to Watir General
Just a guess but the page HTML may have multiple buttons that match value: "OK" (and you're getting the very first one, which isn't the one that you actually want.) It's been a while but think you could add visible: true if that's the case, then it should find the one that you're looking for.

Before posting, please read
In short: search before you ask, be nice.
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages