How to verify if a button is enabled and disabled in Webdriver Python?

The following works for me:

element = driver.find_element_by_name("sub_activate")
prop = element.get_property('disabled')
print (prop)

>>>> False

Returns 'true' if enabled 'element.get_property('enabled')


You are calling is_enabled() on the click() result (None).

Instead, you should first get the element, check if it is_enabled() then try the click() (if that is what you are trying to do).

Take a look at the docs for the methods on the webelement.

is_enabled()
    Whether the element is enabled.

click()
    Clicks the element.

For example:

elem = driver.find_element_by_id("myId")
if elem.is_enabled():
    elem.click()
else:
    pass # whatever logic to handle...

You don't need to call click(). Just find the element and call is_enabled() on it:

element = driver.find_element_by_name("sub_activate")
print element.is_enabled()

FYI, click() is a method on a WebElement, it returns None.