How to write a test case in Selenium IDE (Integrated Development Environment)
Selenium IDE (Integrated Development Environment) is an open source web automation testing tool under the Selenium Suite. Selenium IDE is available only as Mozilla Firefox and Chrome plug-in only. It can not record test cases on browsers other than Firefox and Chrome. The recorded test scripts can also be exported to programming languages like C#, Java, Ruby or Python. It is very easy to install and learn.
The following image shows the default interface of Selenium IDE:
Selenium IDE Features:
Selenium IDE is divided in to several components and that components have their own features and functions. Those are,
- Menu Bar
- Test Case Pane
- Tool Bar
- Address Bar
- Record, Start and Stop Button
- Test Script Editor Box
- Log, Reference Pane
IDE First Test Case
Create the project
We can create a new project by clicking at the “Record a new test in a new project” button.
We can give a project name as Assignment2 and press the OK button.
Open new test case — TestCase_001
Navigate to https://gtmetrix.com/ and press the START RECORDING button.
Figure 4 is showing the Selenium IDE test preparation window. Once we run the test case the website will open. It is showing in Figure 5
In that time our test cases will execute successfully. Figure 6 is showing the Selenium IDE execution.
Click on Blog link and the Selenium IDE is executing successfully. Figure 8 shows the Selenium IDE result. And Figure 7 is showing the output window once we click the Blog button.
Assert the Text “GTmetrix Performance Blog”
To assert the Text “GTmetrix Performance Blog” we right click on the text and go to the Selenium IDE and then select the Assert Text. Figure 9 shows the steps. After that when we execute the Selenium IDE, it will execute successfully. Figure 10 display the Selenium IDE output.
Or else we can use this way also. We can type the commands in command section. And also we can give the target and the values easily.
Verify the Text “New SSL Timing in Waterfall Chart, Capacity Upgrades, and Other Updates”
To verify the Text “New SSL Timing in Waterfall Chart, Capacity Upgrades, and Other Updates”, I searched this topic in the search bar and get the output. Figure 13 is showing the execution of the Selenium IDE. And it is successfully completed. The steps of the verifying the text is display in the Figure 12.
After that we have to save the project as TestCase_001.
Edit above recorded script
According client requirements (SRS), “Whew! A lot of general improvements a maintenance was completed in this release.” Text should be changed as “General improvements and maintenance were completed in this release.”
For that we assert the “Whew! A lot of general improvements a maintenance was completed in this release.” text and it will appear in Figure 15. We can do assert to show the current text. Then the client wants to change that in to “General improvements and maintenance were completed in this release.”. For that we can verify the text and store the new text. Verification is displaying in Figure 16.
In here to verify the text we type the command as Verify Text and find the target and finally type the value that we want to show in the website. Here we have to find the target and Figure 17 display the target.
After that we have to store the new value. Figure 18 is displaying the steps to store the value. And Figure 19 is displaying that, we have to type the new value it will appear popup box to type the value.
Figure 20 is displaying Selenium IDE execution and it did not complete successfully. Because the actual value and current value does not same. So, when we execute the program it will show the error. Because this test case should be fail.
The error message is this.
According client requirements (SRS), id=post-8769 post missing under the id=post-8768. Open the above recorded script and record next test step as verify element fail for id=post-8769
Open new test case — TestCase_002
Create a new test case and save it as TestCase_002.
To do this part, We can search “New Simulated Devices and General Page Analysis Fixes and CDNs” in the search bar and open the topic. Searched result is displaying in Figure 23.
Figure 24 is displaying the output of the Selenium IDE and it is completed successfully.
When we check the inspect, it will show the title the id is displaying as id =post-8768.
We have to write the command to check the id and fail the test case. To do that I wrote command as Verify element present. Here the target that we have to check is id=post-8769. After that wrote the value as “New Simulated Devices and General Page Analysis Fixes and CDNs”. Figure 25 is displaying that part.
After that when we execute the project it will display an error message. Because the ID’s are different.
The error message is this.
The test suite can be found at the location provided in the above steps. Notice that the test script is saved in .side format.
Conclusion
In this article I have covered only how to do a test cases by doing small examples. How can we verify text, assert text, how to store new text and check the title id…etc. Here I do only small test cases to show how we can easily do the test cases by using Selenium IDE. You can see how the error messages are showing in Selenium IDE. Test cases might be pass or fail. In this examples most of the time I did not use type commands, target and values. Without writing like that I used easiest way to do the test cases. You can use any way that you prefer to implement the test cases.
Hopefully, you can now implement your own test cases by using Selenium IDE.
Thank you for going through this article and feel free to leave a few claps if you found this helpful.