How to determine the Disabled property of a 'Button' in Watir

3.5k views Asked by At

How can i check the property of a button whether it is disabled or not? The below statement is sucessfull for its existence,

@browser.frame(:name => 'MainBody').button(:text => 'Submit').exists? 

.. can someone let me know how should i check the disabled property? Thank you!

2

There are 2 answers

0
sebastian.cretu On

In watir-webdriver this can be done by editing the file: C:\Ruby193\lib\ruby\gems\1.9.1\gems\watir-webdriver-0.6.1\lib\watir-webdriver\elements\option.rb and before the def select, add this:

def enabled?
!disabled?
end

It worked for me, as watir-webdriver doesn't know about .enabled? on options for select_lists.

3
p0deje On

@browser.frame(:name => 'MainBody').button(:text => 'Submit').enabled?