Selenum IDE Example of "assertElementPresent" and "assertElementNotPresent" commands

"assertElementPresent" Command

Selenium assert element present command is useful to confirm element availability on page after user taking some action or navigate to some other page. Selenium assert element present will force selenium to stop execution if targeted element not found on the page. It will continue execution if return result of condition "assertElementPresent" = false and will stop execution if return result of condition "assertElementPresent" = true.

In bellow given example, command "assertElementPresent" will verify that element "id=gbqfba" is there on the page or not. if element "id=gbqfba" (google search button) found on the page then it will execute next
command else it will return true in execution log and stop the execution.

New Test
CommandTargetValue
openhttps://www.google.co.in/
assertElementPresentid=gbqfba
typeid=gbqfqsoftware testing tutorials automation blog
clickid=gbqfb
pause3000
assertElementNotPresentid=gbqfb
typeid=gbqfqdownload selenium ide free

"assertElementNotPresent" command

in the opposite condition, selenium assert element not present command will stop selenium execution if targeted element found on the page. In above example, "assertElementNotPresent" command verifies that element "id=gbqfb" (google search button) is there on the page? If yes then it will stop execution else it will execute next command. This way you can use selenium assert element present and selenium assert element not present commands.

No comments:

Post a Comment