HomeSelenium

New Selenium IDE – Using ‘assert alert’ command to check whether the alert is displayed

New Selenium IDE – Using ‘assert alert’ command to check whether the alert is displayed

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

assert alert is one of the commands in Selenium IDE.

The purpose of assert alert command in Selenium IDE, is to check whether the required alert is displayed on the page.

In this article, I am going to practically demonstrate assert alert command in Selenium IDE for checking whether the required alert is displayed on the page as shown below:

assert alert Selenium IDE - demo

Let’s get started.

New Selenium IDE – Using ‘assert alert’ command to check whether the alert is displayed

Follow the below steps for practicing assert alert 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 ‘click’ to the Command box field, enter the id locating strategy id=alert1 into the Target box field as shown below:

Note: The locating strategy id=alert1 is for locating the ‘ClickToGetAlert’ button on the http://omayo.blogspot.com/ URL page (Shown at the beginning of the article).

We are doing this to click on the ‘ClickToGetAlert’ button to display the alert.

Note: Though we are able to see the Alert dialog with ‘Hello’ text when we click on the ‘ClickToGetAlert’, but Selenium IDE while executing the script won’t be visually showing the alert.

assert alert Selenium IDE - type one

4) Select the step 3 in the Selenium IDE Script Editor box, enter the Selenium IDE command ‘assert alert’ to the Command box field, enter the text that will be displayed on the alert i.e. ‘Hello‘ into the  Target box field as shown below:

Note: We need to use the ‘Hello’ text that will be displayed on the alert to assert the alert (I have shown this ‘Hello’ text on the article at the beginning of the article).

assert alert Selenium IDE - type two

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

assert alert Selenium IDE - run

6) Observe that the assert alert command in the Selenium IDE will be executed, and the result will be passed as shown below as the alert with the text ‘Hello’ will be displayed as expected:

assert alert Selenium IDE - executed

Note: In the above-executed test, though the alert is displayed with ‘Hello’ text, Selenium IDE will not be showing alerts during execution. Hence we need to assume that the alert got displayed though it is not visually seen as displayed on the screen.

We have checked that the required alert with text ‘Hello’ is displayed. Let’s now intentionally fail the test by asserting the alert with a non-existing text.

7) Let’s modify the text given into the Targe field from the above given ‘Hello’ text to ‘XYZ’ wrong text as shown below:

assert alert Selenium IDE - demo fail

8) Click on ‘Run current test’ option and observe that the assert alert command in the Selenium IDE will be executed, and the result will be failed as shown below:

assert alert Selenium IDE - executed fail

Here concludes the practical demonstration of assert alert 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 ?

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 (0)

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