I want to check if button is enabled or not. Sadly there is no such attribute which can distinguish between button being enabled or disabled.
The HTML code is as below:
<input _ngcontent-iuv-c99="" type="checkbox" id="IDofButton" name="NameOfButton" formcontrolname="XYZ" class="ng-untouched ng-pristine ng-valid">
<i _ngcontent-iuv-c99="" tabindex="0"></i>
[Toggle button image in on and off state][https://i.stack.imgur.com/keZWq.png]
No change is seen when we toggle button to on or off. How to make WebDriver Know if button is enabled or not.
Selenium knows a button is enabled or not using the html disabled property. you can use the is enabled method
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/WebElement.html#isEnabled()
This returns true or false. This works only if enable and disable is achieved using html disable property.
https://www.w3schools.com/tags/att_disabled.asp
IF the the button is enabled or disabled using css styling then you should check for specific class change or any attribute change to validate if the button got disabled or not.
IN this case use
validate it is as expected.
But in this case also even if the class css styling had issues it won't be caught in selenium thats why exploratory manual testing is still important for UI