Selenium assertion "assertChecked" and "assertNotChecked" with example

There are many assertions available in selenium. Here i am going to describe "assertchecked" and "assertNotChecked" assertion in selenium IDE with example. "assertNotChecked" and "assertchecked" commands works with only check box and radio button. Both the commands are used for verifying check
status of check box or radio button.

Selenium "assertchecked" assertion command
You need to provide checkbox or radio button's Element locator in target column with "assertchecked" command. It will check and verify that targeted element is checked or not. If targeted element is not checked then selenium IDE will return "[error] false" in execution log and remaining commands will be not executed. If targeted element is already checked then command execution will becomes pass and selenium IDE will go for executing next command.

Selenium assertion "assertNotChecked" command
Opposite to "assertchecked" command, "assertNotChecked" assertion will return "[error] true" if targeted check box or radio button is already checked and stop remaining command's execution. Else it will be pass and selenium IDE will go for executing next command.

Run bellow example in your selenium IDE to experiment it yourself.

New Test

In this example, 'css=#PersistentCookie' is CSS element locator of 'Stay signed in' check box on Google account log in page. "assertNotChecked" will be pass because 'Stay signed in' check box is not checked. Next command "assertChecked" will fail and return "[error] false" in log and selenium will stop execution immediately.

1 comment: