Refer the article New Selenium IDE – Commands (Selenese), for the complete list of Selenium IDE commands and their practical demonstrations.
assert element not present is one of the commands in Selenium IDE.
The purpose of assert element not present command in Selenium IDE, is to check whether the given UI element is not present on the page.
In this article, I am going to practically demonstrate assert element not present command in Selenium IDE for checking whether the UI element is not present on the page. i.e. I will give a locating strategy which doesn’t locate any UI element on the page in Selenium IDE, to get this command passed in the results.
Note: This command is an opposite of assert element present command explained in the previous article.
Let’s give a locating strategy id=buttonxyz which will not be able to locate any UI element on the page.
Let’s get started.
New Selenium IDE – Using ‘assert element not present’ command to check the UI element is not present on the page
Follow the below steps for practicing assert element not present command in Selenium IDE along with me:
1) Execute the open command in Selenium IDE as explained in the previous article: Selenium IDE – open command
2) Now click on the second row in the Selenium IDE’s Test Script Editor Box as shown below:
3) While the second row is selected in step 2, enter the Selenium IDE command ‘assert element not present’ to the Command box field, enter the id locating strategy id=butxyz into the Target box field as shown below:
Note: The locating strategy id=buttonxyz is won’t be able to locate any UI element on the http://omayo.blogspot.com/ URL page (Explained at the beginning of the article).
4) Click on ‘Run current test’ option as shown below:
5) Observe that the assert element not present command in the Selenium IDE will be executed, and the result will be passed as shown below as the given locating strategy won’t be able to locate any UI element on the page.
We have checked that the required UI element of the given locating strategy is not available on the page, then the test will pass.
Now, let’s fail the test by giving a locating strategy of a UI element that is available on the page say id=but2 which locates the Button2 button on the page.
6) Now let’s modify the locating strategy to id=but2 as shown below which locates the Button2 button on the page in the above example to fail the test case.
7) Click on ‘Run current test’ option and observe that the assert element not present command in the Selenium IDE will be executed, and the result will be failed as shown below as the UI element is present on the page.
Here concludes the practical demonstration of assert element not present command in Selenium IDE.
In the next article, I will practically demonstrate another Selenium IDE command.
Next Steps:
- > To learn more about Selenium, continue to the next post (Click on Next Post link below)
- > Check complete Selenium Tutorial Contents here (Click here)
Please leave your questions/comments/feedback below.
Happy Learning ?
On a mission to contribute to the Software Testing Community in all possible ways.
Refer the article New Selenium IDE – Commands (Selenese), for the complete list of Selenium IDE commands and their practical demonstrations.