Quick Start into Selenium Tests

Exclusive offer: get 50% off this eBook here
Instant Selenium Testing Tools Starter [Instant]

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

$12.99    $6.50
by Unmesh Gundecha | May 2013 | Open Source

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:

  1. Launch the Firefox browser.

  2. Open the website for testing in the Firefox browser. For this example we will use http://demo.magentocommerce.com/.

  3. Open Selenium IDE from the Tools menu.

  4. 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.

  5. Now switch back to the Firefox browser window and type Nokia in the search textbox and click on the Search button as shown:

  6. 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.

  7. 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:

  8. 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:

  1. Select File | Save Test Case from the Selenium IDE main menu:

  2. 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:

  1. Select File | Save Test Suite from the Selenium IDE main menu.

  2. In the Save As dialog box, enter the test case name as SearchFeatureTests.html and click on the Save button.

  3. 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

    1. Select the test which you want to execute from the test suite pane and click on the (play current test case) button .

    2. 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.

Summary

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 :


Further resources on this subject:


Instant Selenium Testing Tools Starter [Instant] A short, fast, and focused guide to Selenium Testing tools that delivers immediate results with this book and ebook
Published: April 2013
eBook Price: $12.99
See more
Select your format and quantity:

About the Author :


Unmesh Gundecha

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.

Books From Packt


 BackTrack 4: Assuring Security by Penetration Testing
BackTrack 4: Assuring Security by Penetration Testing

 CherryPy Essentials: Rapid Python Web Application Development
CherryPy Essentials: Rapid Python Web Application Development

Instant Eclipse 4 RCP Development How-to [Instant]
Instant Eclipse 4 RCP Development How-to [Instant]

Selenium 1.0 Testing Tools: Beginner’s Guide
Selenium 1.0 Testing Tools: Beginner’s Guide

 Python Testing Cookbook
Python Testing Cookbook

Instant Pygame for Python Game Development How-to [Instant]
Instant Pygame for Python Game Development How-to [Instant]

 Selenium Testing Tools Cookbook
Selenium Testing Tools Cookbook

 Selenium 2 Testing Tools: Beginner’s Guide
Selenium 2 Testing Tools: Beginner’s Guide


Your rating: None Average: 1.8 (4 votes)

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Y
z
A
P
4
H
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software