How to Create a Script Using the Recording Feature in Selenium IDE
We will learn here how to create a script using the recording feature in Selenium IDE. Hope you are visiting this page after you have grasped the basics revolving around Selenium IDE in Firefox.
As seen in that chapter we had talked about the recording button provided by the Selenium IDE window. It records whatever you do on your browser. It takes into account all those Selenium IDE commands that we had seen before and uses them to get the job done.
We will not waste a moment more, and start creating our script with the recording feature offered by Selenium IDE. Learn how to create a script using the recording feature in Selenium IDE.
How to Create a Script using the Recording Feature in Selenium IDE
Once you create your first script you will understand things better, I pinky promise. I have listed a step by step process to do that.
Step 1: Open Selenium IDE if you haven’t already opened it.
Step 2: Click on Base URL textbox and enter the URL that needs to be tested. I am taking Google for a ride:
As you enter something in the base URL field, recording automatically begins. If it hasn’t you can check that out yourself. There’s a red recording button available towards the right-hand side as shown:
Make sure that it is On. You can check that by placing your mouse over it. It would read “Now Recording. Click to Stop Recording” as a label.
NOTE: From this point onwards everything you do on the browser will get recorded.
Step 3: Now enter the same URL in Firefox’s Address Bar and press enter. Let the website open in your Firefox browser.
Step 4: Right click on the blank area and navigate to “Show All Available Commands”. You will get a list of commands that you can use herefrom.
You can select any option you wish to select based on your requirement. I am going to select the verifyTitle option to grab the title of the website I have opened.
I have clicked on verifyTitle Google.
So trying to look at from a testing perspective, our test case is just trying to establish if the title name of the website is correct or not.
At the Editor Pane
Step 5: Navigate back to the opened suite. (Just do Alt + Tab or something to bring the dialog box in front). You will see an Untitled suite has been created automatically with the Editor pane populated with the following info:
As you can see the first command has been already populated with open with the target automatically taken from your address bar. So it is in a way saying that you used the open command to open the target.
The second command is that of verifyTitle that has a target that reads “Google”.
Step 6: Since we are on the Google Page we might as well type something in its search bar and press enter:
Woah! my website flares up. 🙂
Step 7: Now that you go back to the Selenium IDE window and check, you will find a third command lurking there.
As we already know our command corresponds perfectly to “type”, we did type didn’t we? And the value of it shows as Dumb It Dude which is exactly what we had typed.
Step 8: When you think you are done you can stop the recording by pressing the Red button on the Suite.
No further recording will be carried out once you click on the button. No steps will be recorded after that.
The next step is to save your test case. Another set of steps from “how to use Selenium IDE in Firefox” basket, you should really pay attention to when you are wishing to share your test case.
Saving your Test Case
Step 9: Press Ctrl + S or navigate to File > Save Test Case to save the test case.
When you click on it, a “save test case” dialog box will open. Choose the location where you wish to store your file.
Step 10: Click on Save. When you do the file will be saved in the location you chose.
The format of the file saved would be .html.
Step 11: Open the saved file in any browser of your choice. I have simply double clicked on it to open it in my default browser. Here’s what I get:
You will get the test case info in the above tabular form, just as was depicted in your editor. This can come in really handy when you have to share test cases with your client, or other team members.
We are not done yet. This is yet another crucial step of how to use Selenium IDE in Firefox.
Step 12: Navigate back to Selenium IDE and click on the green Play button that’s shown on the top toolbar. If there are many test cases in your test suite and you want only a particular test case to be executed you can use the second green button. But here we have just one, so selecting any of them wouldn’t matter.
Step 13: Click on the first green button to execute the suite.
Test execution will happen and you will notice the test case has been colored in green.
Green means Pass.
It is an indication of a passed suite. If it is red that means the test case has failed. With that concludes our chapter on how to create a script using the recording feature in Selenium IDE.
Alright, so now that you have learnt how to create a script using the recording feature in Selenium IDE it is time to learn how to do that manually too. Pay attention to this one, it is really important too.