Home > Enterprise >  how to verify a disabled button in Python Selenium
how to verify a disabled button in Python Selenium

Time:08-16

"<button  disabled type="button" xpath="1">submit Button</button> (flex)"

def isButtonDisabled(self):

element = self.element.findElement(By.xpath, 'locator')
return element.get_property('disabled')

but this method is not working

CodePudding user response:

There is a function in WebDriver called is_enabled which returns true if the element is enabled, else it returns false.

def isButtonDisabled(self):
    element = self.element.findElement(By.xpath, 'locator')
    return element.is_enabled()

Here's a Reference in the documentation of selenium py

CodePudding user response:

"disabled" is not a property, but attribute so you need to replace

element.get_property('disabled')

with

element.get_attribute('disabled')

CodePudding user response:

disabled Attribute

The disabled attribute is a boolean attribute which specifies that the element should be disabled unless some prerequisites are met. A disabled element is unusable. Generally the disabled attribute can be set to keep a user from using the element until some other condition has been met e.g. selecting a checkbox, radio button, etc.

  • Related