Button Assertions

Look at the details of Selenium button assertions, and test it out yourself.

Assert if a button is present

Just like hyperlinks, we can use isDisplayed() to check whether a control is present on a web page or not. This check applies to most of the web controls in Selenium. In the following script, we are first using isDisplayed() function to check the presence of Selenium button on the web page. Once its presence is assured, we then move on to change its properties from visible to hidden and then to visible again while asserting it at each step.


Assert if a button is disabled

A web control can be in a disabled state as well. A disabled button is unclickable, and is displayed as:

Get hands-on with 1200+ tech skills courses.