Button enabled or disabled : How does webdriver decide?

前端 未结 2 1169
野性不改
野性不改 2020-12-16 22:26

How does selenium webdriver decide whether a button is enabled or disabled? I have used the isEnabled() method for two buttons - one enabled and the other disabled but i

相关标签:
2条回答
  • 2020-12-16 22:38

    isEnabled() checks for the disabled attribute on the button element. If the attribute "disabled" is not present, it returns True, so if you never add this attribute to disabled buttons and instead add the value "disabled" to the button's class, isEnabled() will always return true.

    If you are determining whether the button is enabled or disabled based on a class, you will need to instead check for the existence of a button with the "disabled" class (find it by class name, xpath, or CSS selector) to decide what state the button is in.

    0 讨论(0)
  • 2020-12-16 22:41

    isEnabled() is a good answer, but it has recently been updated to just Enabled, as a getter on the IWebElement.

    Example:

    Driver.findElement(By.Class("example-class-name")).Enabled

    Cheers!

    0 讨论(0)
提交回复
热议问题