How to write a test case in Selenium IDE (Integrated Development Environment)

Prabhavi Jayanetti
7 min readSep 2, 2020

--

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,

  1. Menu Bar
  2. Test Case Pane
  3. Tool Bar
  4. Address Bar
  5. Record, Start and Stop Button
  6. Test Script Editor Box
  7. Log, Reference Pane

IDE First Test Case

Create the project

Figure 1

We can create a new project by clicking at the “Record a new test in a new project” button.

Figure 2

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 3

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

Figure 4
Figure 5

In that time our test cases will execute successfully. Figure 6 is showing the Selenium IDE execution.

Figure 6

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.

Figure 7
Figure 8

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.

Figure 9
Figure 10

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.

Figure 11

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.

Figure 12
Figure 13

After that we have to save the project as TestCase_001.

Figure 14

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.

Figure 15
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.

Figure 17

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 18
Figure 19

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.

Figure 20

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

Figure 21: ID and the title

Open new test case — TestCase_002

Create a new test case and save it as TestCase_002.

Figure 22

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 23

Figure 24 is displaying the output of the Selenium IDE and it is completed successfully.

Figure 24

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.

Figure 25

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.

--

--

Prabhavi Jayanetti
Prabhavi Jayanetti

Written by Prabhavi Jayanetti

SAP Consultant - ABAP | Academic Instructor | Sri Lanka Institute of Information Technology. Visit me @ https://www.linkedin.com/in/prabhavi-jayanetti-5b900418a

No responses yet