I tried using the following from another post
driver.find_element_by_name("sub_activate").click().is_enabled()
but got this error:
AttributeError: 'NoneType' object has no attribute 'is_enabled'
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.
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...
IWebElement button = driver.FindElement(By.Id("ButtonId"));
Assert.AreEqual(false, button.Enabled); /*Validates whether the button is Disabled*/
Assert.AreEqual(true, button.Enabled); /*Validates whether the button is Enabled*/
driver.find_element_by_name("sub_activate").click().is_enabled()
In the above method you have used click() method. Without using it you can verify whether a button is disabled or enabled. It returns a Boolean value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With