Selenium IDE – An Introduction
Selenium provides a record/playback tool for authoring tests without learning a test scripting language (Selenium IDE) and Selenium IDE is first component developed for Firefox.
- Selenium IDE, fully-featured Integrated Development Environment (IDE)
- Installs as a plugin in Mozilla Firefox and not available for other browsers.
- Enables developers to test their web applications through Selenium
- Records user interactions with the web browser and playback to test for errors
- Easy to install and easy to learn.
Installation of Selenium IDE
First, we need to download Selenium IDE from Google and its available as Firefox plugin and follow the below steps.
- Copy Selenium IDE file to extensions folder of Mozilla Firefox.
- To facilitate opening of the .xpi file for selenium you can drag and drop the .xpi file on the Mozilla browser to install it and get it in the add-ons of the browser
Components of Selenium IDE
Selenium IDE has the list of components we will go for each and every component take a quick look into the below picture.
- Positioned at the uppermost of the Selenium IDE window
File menu option allows a user to do below operations:
- Create new test case, open existing test case, save the current test case.
- Export Test Case As option exports and converts only the currently opened Selenium IDE test case
- Export Test Case As and Export Test Suite As options are used to convert from IDE to programming script such that it can be used in Selenium RC and WebDriver.
- Close the test case.
When user click on File menu and it will be shown like below picture.
Contains buttons for controlling the execution of your test cases.
Step feature for debugging your test cases
Speed Control: Controls how fast your test case runs.
Run All: Runs the entire test suite when a test suite with multiple test cases is loaded
Run: Runs the currently selected test. When only a single test is loaded this button and the Run All button have the same effect
Pause/Resume: Allows stopping and re-starting of a running test case
Step: Allows you to “step” through a test case by running it one command at a time. Use for debugging test cases.
Apply Rollup Rules: This advanced feature allows repetitive sequences of Selenium commands to be grouped into a single action. Detailed documentation on rollup rules can be found in the UI-Element Documentation on the Help menu.
Record: Records the user’s browser actions.
Test Case Pane
The script is displayed in the test case pane
It has two tabs:
- Displays the command and their parameters in a readable “Table” format.
- “Source” displays the test case in the native format in which the file will be stored.
- By default, this is HTML although it can be changed to a programming language such as Java or C#, or a scripting language like Python.
Command, Target, and Value
- The command displays the currently selected command along with its parameters.
- Target displays unique tag value for the selected field.
- Value contains the data in case of text box fields.
- The bottom pane is used
- Log: Error messages and information messages showing the progress are displayed automatically.
- Reference: Displays documentation on the current command in table mode.
- UI-Element and Rollup: Detailed information on these two panes (which cover advanced features) can be found in the UI-Element Documentation on the Help menu of Selenium-IDE.
Introduction to Selenium Commands – “Selenese”
- Set of commands used by selenium to automate the web application testing
- Combination of Selenese commands creates test script 3A’s
Selenese is a combination of as 3A’s:
- Action: Used to change the state of the AUT(Application under Test)
E.g.: Click, close, doubleclick
- Accessor: Check the state of application & save state in some variable
E.g.: storeTitle , storeElementPresent
- Assertions: Verifies the state of the application matches it with the expected state and generates the True/False result
E.g. : verifyText, assertText
Understanding Element Locators in Selenium IDE
Each and every element in a web page is associated with locator based on element locator you can able to find the element.
Types of Element Locators:
- Link Text
- CSS Selector
- Tag and ID
- Tag and class
- Tag and attribute
- Tag, class, and attribute
- Inner text
- DOM (Document Object Model)
- dom: index
Locating by ID
Locating by NAME
Locating by Link Text
Locating by CSS Selector – Tag and ID
Locating by CSS Selector – Tag and Class
Locating by CSS Selector – Tag and Attribute
Locating by CSS Selector – Tag, Class, and Attribute
Locating by CSS Selector – Inner text
Locating by DOM – getElementsById
Locating by DOM – getElementsByName
Locating by DOM – DOM: Name
Locating by DOM – DOM: Index
Locating by XPath
Working With Alerts
The simplest form of pop-up windows is nothing but Alerts. Generally, while testing application you may face alerts when you user misses any mandatory fields or application providing any information then you user need to click the alert and dismiss the alert then the only user can move into the application.
When running automation script you may face alert in that case you need to handle alerts and
most common Selenium IDE commands used in handling alerts are the following :
Creating Test Scripts using Selenium IDE
First, open the application which you going to be tested in a browser. Copy the application URL(base URL)
Click on IDE plugin installed in the browser to launch selenium IDE and enter baser URL of an application which you want to test.
Hit the record button on IDE and the browser will be launched automatically with application “Google” website and now Enter the text on Web Page and submit
IDE should be updated, stop the recorder and add the assertions.
The moment you stopped the recorder script will be generated and displayed and you can customize/enhance script as per your wish. Now you can play the same script you can run any number of times.
When you hit the play button IDE will imitate the recorded scenario and result will be like below,
Exporting scripts to multiple languages and Formats
One more benefit from IDE is once you recorded the script you can export script below mentioned languages you want then you can run the script from Eclipse IDE tool where you can customize/enhance the scripts further.
Test cases can be exported only to the following formats:
- .cs (C# source code)
- .java (Java source code)
- .py (Python source code)
- .rb (Ruby source code)
In this lesson, you have learned
- Selenium IDE (Integrated Development Environment) is the simplest tool in the Selenium Suite.
- The menu bar is used in creating, modifying, and exporting test cases into formats usable by Selenium RC and WebDriver
- The default format for Selenese commands is HTML.
- The Test Case Pane shows the list of currently opened test cases and a concise summary of test runs
- Locators tell Selenium IDE which GUI elements ( say TextBox, Buttons, Check Boxes etc.) it needs to operate on.
- The choice of locator depends largely on your Application Under Test.