Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Selenium Testing Tools - Third Edition

You're reading from   Learning Selenium Testing Tools - Third Edition Leverage the power of Selenium to build your own real-time test cases from scratch

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher
ISBN-13 9781784396497
Length 318 pages
Edition 3rd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Raghavendra Prasad MG Raghavendra Prasad MG
Author Profile Icon Raghavendra Prasad MG
Raghavendra Prasad MG
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Getting Started with Selenium IDE FREE CHAPTER 2. Locators 3. Overview of the Selenium WebDriver 4. Finding Elements 5. Design Patterns 6. Working with WebDriver 7. Automation Framework Development and Building Utilities 8. Mobile Devices 9. Getting Started with the Selenium Grid 10. Advanced User Interactions 11. Working with HTML5 12. Advanced Topics 13. Migrating from Remote Control to WebDriver A. Automation Prerequisites for Selenium Automation B. Answers for Self-test Questions Index

Parameterization

Parameterization is a key feature in automation testing. It is possible to give test data (parameter) as input in Selenium IDE as it is with any other automation tool. Selenium IDE requires configuration before proceeding for parameterization, which is explained in the following section.

After configuring Selenium IDE for parameterization, in the following example, we will search a text on Google and verify the text appears on the page. The storeEval command will read the search data from the google_search.js file and save it in the searchDataValue variable. With this variable, data types on the Google search page, verify Download Selenium IDE text using the assertTextPresent command. In this way, you can achieve data parameterization or data-driven testing by passing external data to a variable in Selenium IDE.

Selenium IDE Configuration

You need to create JavaScript file as the data source file. These are the steps to create JavaScript file and configure Selenium IDE:

  1. In a Notepad, create input data as follows:
    searchData = 'Selenium IDE'
  2. Save it as a file, say for example, google_search.js.
  3. Open Selenium IDE and choose the Option | Options… menu.
  4. Under Selenium IDE Extensions, browse the saved google_search.js file. After attaching the data file, your Selenium IDE option window will look like the following screenshot. Then, click OK and restart the Selenium IDE:
    Selenium IDE Configuration
  5. Now, record the script to perform Google search and verify the page element and update the commands as shown in the following screenshot. Then, execute the test. You can also use the WaitForElementPresent command till the page element is loaded and verify instead of the pause command.
    Selenium IDE Configuration

In this example, we are searching a text on the Google page and verifying the text appearing on the page. The storeEval command will read the search data from the google_search.js file and store it in a searchDataValue variable and verify the Download Selenium IDE text using an assertTextPresent command. In this way, you can achieve data parameterization or data-driven testing in Selenium IDE.

Generating source code from Selenium IDE

The Selenium IDE formatters plugin enables you to export the recorded steps. Selenium IDE can export the recorded steps or user actions to different formats. The Selenium team provides bindings for several programming languages. You can write a script in one of these programming languages and use the provided libraries to remotely control a browser. Selenium IDE formatters convert the recorded actions into source code for a specific programming language.

You need to set enable experimental features on Selenium IDE options to view the formatters. Check out the following screenshot for formatters:

Generating source code from Selenium IDE

Record user actions on Selenium IDE, and to view specific programming language formatters, select the Selenium IDE | Options | Format as shown in the following screenshot. A confirmation dialog appears, click on OK:

Generating source code from Selenium IDE

Ensure that the code is displayed under the Selenium IDE Source tab as seen in the screenshot that follows. You can also see the Java/Junit4/WebDriver programming language formatter. Selenium IDE used the type command to identify text typing into the textbox. In the source code, the sendkeys command is used in order to type text into the textbox using the Selenium Java/Junit4/WebDriver programming language. You can generate a formatter of any of the specific programming languages. After viewing the source code, you can switch back from a specific formatter to HTML. If a formatter is not HTML, then recording options will not work and the Table tab will not be active:

Generating source code from Selenium IDE

In the preceding recorded action, we searched a text on Google and verified the text appears on the page. Selenium IDE exports these actions to view a specific programming language. This is one of the useful features of Selenium IDE; it provides an option to set the clipboard format. You can copy commands from the Table tab and paste in the format of that specific programming language.

You have been reading a chapter from
Learning Selenium Testing Tools - Third Edition - Third Edition
Published in: Feb 2015
Publisher:
ISBN-13: 9781784396497
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image