HomeSelenium

New Selenium IDE – Using ‘verify element not present’ command to check the UI element is not present on the page

New Selenium IDE – Using ‘verify element not present’ command to check the UI element is not present on the page

Refer the article New Selenium IDE – Commands (Selenese), for the complete list of Selenium IDE commands and their practical demonstrations.

verify element not present is one of the commands in Selenium IDE.

The purpose of verify element not present command in Selenium IDE, is to check whether the given UI  element is not present on the page.

Difference between assert element not present and verify element not present commands

Though the purpose of assert element not present and verify element not present commands are same, verify element not present command will act as a soft assertion.

If the verify element not present command fails in Selenium IDE, the execution won’t stop and the steps which come after the failed verify element not present step will be executed.

Whereas if the assert element not present command fails during execution, the complete execution will stop there itself and the steps which come after the failed assert element not present won’t be executed.

In this article, I am going to practically demonstrate verify 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 the opposite of verify 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 ‘verify element 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:

type Selenium IDE - click Row

3) While the second row is selected in step 2, enter the Selenium IDE command ‘verify 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).

verify element not present Selenium IDE - typing

4) Click on ‘Run current test’ option as shown below:

verify element not present Selenium IDE - run

5) Observe that the verify 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.

verify element not present Selenium IDE - executed

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 as shown below:

verify element not present Selenium IDE - fail

 

Here concludes the practical demonstration of verify element not present command in Selenium IDE.

As already explained above, verify element not present command when failed won’t stop the complete execution and the steps which come after the verify element not present command will be executed. Whereas assert element not present command when failed will stop the complete execution and the steps which after the assert element not present command won’t be executed. The below screenshot proves it:

verify element not present Selenium IDE - difference

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 ?

About Me > Arun Motoori

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.

Comments (1)

  • Hey Arun
    I enjopy your Selenium related posts. Thanks.

    Question, “verify element present” by itself is useless. Can you explain how you check the output and make a decision using an if statement?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp