Instant Selenium Testing Tools Starter [Instant] — Save 50%
A short, fast, and focused guide to Selenium Testing tools that delivers immediate results with this book and ebook
In this article by Unmesh Gundecha, author of Instant Selenium Testing Tools Starter, we will show you how to record a test using Selenium IDE. During the recording, we will add some additional commands to the test and run the recorded test.
A test is a basic building block in Selenium IDE. It contains commands for navigation, test steps, and checks for expected versus the actual state of the application. In this article we will show you how to create your first test and execute this test with Selenium IDE.
(For more resources related to this topic, see here.)
Step 1 – Recording and adding commands in a test
In this section we will show you how to record a test on a demo e-commerce application. We will test the product search feature of the application using the following steps:
Launch the Firefox browser.
Open the website for testing in the Firefox browser. For this example we will use http://demo.magentocommerce.com/.
Open Selenium IDE from the Tools menu.
Selenium IDE by default sets the recording mode on. If it's not pressed, you can start recording by pressing the (record) button in the top-right corner.
Now switch back to the Firefox browser window and type Nokia in the search textbox and click on the Search button as shown:
Check if the link Nokia 2610 Phone is present in the search results. We can do that by selecting the link and opening the context menu (right-click) and selecting Show All Available Commands | assertElementPresent link=Nokia 2610 Phone.
Next, we will click on the Nokia 2610 Phone link to open the product page and check if the Nokia 2610 Phone text is displayed on the product page. To do this, select the Nokia 2610 Phone text and open the context menu (right-click) and select Show All Available Commands | assertTextPresent link=Nokia 2610 Phone:
Go back to Selenium IDE. All the previous steps are recorded by Selenium IDE in the Command-Target-Value format as shown in the following screenshot. Stop the recording session by clicking on the Recording button:
Step 2 – Saving the recorded test
Before we play back the recorded test, let's save it in Selenium IDE:
Select File | Save Test Case from the Selenium IDE main menu:
In the Save As dialog box, enter the test case name as SearchTest.html and click on the Save button. The test will be saved with the name SearchTest.
Step 3 – Saving the test suite
In Selenium IDE, we can group multiple tests in a test suite. Let's create a test suite and Selenium IDE will automatically add SearchTest to this suite:
Select File | Save Test Suite from the Selenium IDE main menu.
In the Save As dialog box, enter the test case name as SearchFeatureTests.html and click on the Save button.
You can create and record more than one test case in a test suite.
Step 4 – Running the recorded test
Selenium IDE provides multiple ways to execute the tests:
Option 1 – running a single test case
Select the test which you want to execute from the test suite pane and click on the (play current test case) button .
Selenium IDE will start the playback of the test and you can see the steps that we recorded earlier are being played automatically in the browser window. At end of execution, Selenium IDE will display results as per the following screenshot:
Option 2 – running all tests from a test suite
If you have multiple tests in a test suite, you can use the (play the entire test suite) button to play all the test cases.
After the test is executed in Selenium IDE, you can see the results in Log tab. All the steps which are successfully completed will be heighted in green and checks in dark green. If there are any failures in the test, those will be highlighted in red. This is how Selenium IDE helps you testing your web application.
We learned how to record a test, save a test case, enhance a test by adding commands, and run a test with Selenium IDE. This article also got you started on with programming with Selenium WebDriver.
Resources for Article :
- Python Testing: Installing the Robot Framework [Article]
- First Steps with Selenium RC [Article]
- User Extensions and Add-ons in Selenium 1.0 Testing Tools [Article]
|A short, fast, and focused guide to Selenium Testing tools that delivers immediate results with this book and ebook|
eBook Price: $12.99
About the Author :
Unmesh Gundecha has a Master’s Degree in Software Engineering and around 10 years of experience in Software Development and Testing. Unmesh has architected functional test automation projects using industry standard, in-house and custom test automation frameworks along with leading commercial and open source test automation tools. Presently he is working as Test Architect with a multinational company in Pune, India.
He is also author of Selenium Testing Tools Cookbook published by Packt in November 2012.