Button enabled or disabled : How does webdriver decide?

前端 未结 2 1174
野性不改
野性不改 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条回答
  •  旧时难觅i
    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.

提交回复
热议问题