Refer the article New Selenium IDE – Commands (Selenese), for the complete list of Selenium IDE commands and their practical demonstrations.
if is one of the commands in Selenium IDE and we need to end it with end command.
if and end are two commands in Selenium IDE which can be used together.
The purpose of the if command is to check whether the given condition is true or false. If the condition results in true, the Selenium IDE statements inside the if and end commands will be executed. If the condition results in false, the Selenium IDE statements inside the if and end commands won’t be executed (i.e. skipped from execution).
The if and end commands will work as depicted below:
Let’s get started.
New Selenium IDE – Using ‘if’ and ‘end’ commands
Follow the below steps for practicing if and end commands in Selenium IDE along with me:
1) Let’s create a test in Selenium IDE for retrieving the title of the page, adding if condition to check whether the retrieved title is equal to the expected title text and printing the result using the below Selenium IDE code:
[su_table alternate=”no”]
Command | Target | Value |
---|---|---|
open | http://omayo.blogspot.com/ | |
store title | x | |
if | ${x} === “omayo (QAFox.com)” | |
echo | Correct title is displayed on the web page | |
end |
[/su_table]
After incorporating the commands in the above table, our Selenium IDE should look like below:
2) Click on ‘Run current test’ option and observe that the test got successfully executed and the text ‘Correct title is displayed on the page’ is printed in the Log tab as shown below:
Here concludes the practical demonstration of if and end commands in Selenium IDE.
In the next article, I will practically demonstrate another Selenium IDE command.
Next Steps:
- > 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.