Search code examples
rubywatir-webdriver

Ruby - Watir-Webdriver - Clicking on a button that is 'disabled'


The version of watir-webdriver I am using (0.6.10) has an #assert_enabled method that executes of any #click you call using watir-webdriver.

I want to click on a button and I don't care that watir-webdriver thinks it is disabled (it's not even though #disabled? returns true for the element).

What can I do?

Disabled is in quotes because watir-webdriver 0.6.10 incorrectly returns true for #disabled? sometimes.


Solution

  • Given that you are using Watir-Webdriver v0.6.10, the first thing I would recommend is upgrading to latest for Watir (where Watir v6.2.0 is the latest version of Watir-Webdriver), Selenium-WebDriver and drivers. There may have been fixes that address your root problem of the enabled element being detected as disabled.

    If that does not work, providing a reproducible test case so that Watir and/or Selenium can be fixed would be the next step.

    As @phoet mentioned in the comments, if you really just want to ignore all of the assertions, you can directly fire the click event for the element:

    element.fire_event('onclick')