Wednesday, December 31, 2014

Selenium - IDE Test Creation

The following steps are involved in creating Selenium tests using IDE:
  • Recording and adding commands in a test
  • Saving the recorded test
  • Saving the test suite
  • Executing the recorded test

Recording and Adding Commands in a Test

We will use www.ncalculators.com to demonstrate the features of Selenium.
Step 1 : Launch the Firefox browser and navigate to the website - http://www.ncalculators.com/
Step 2 : Open Selenium IDE from the Tools menu and press the record button that is on the top-right corner.
Selenium IDE 7
Step 3 : Navigate to "Math Calculator" >> "Percent Calculator >> enter "10" as number1 and 50 as number2 and click "calculate".
Selenium IDE 7
Step 4 : User can then insert a checkpoint by right clicking on the webelement and select "Show all available commands" >> select "assert text css=b 5"
Selenium IDE 8
Step 5 : The recorded script is generated and the script is displayed as shown below.
Selenium IDE 9

Saving the Recorded Test

Step 1 : Save the Test Case by navigating to "File" >> "Save Test" and save the file in the location of your choice. The file is saved as .HTML as default.
The test can also be saved with an extension htm, shtml, and xhtml.
Selenium IDE 9

Saving the Test Suite

A test suite is a collection of tests that can be executed as a single entity.
Step 1 : Create a test suite by navigating to "File" >> "New Test Suite" as shown below.
Selenium IDE 13
Step 2 : The tests can be recorded one by one by choosing the option "New Test Case" from the "File" Menu.
Step 3 : The individual tests are saved with a name along with saving a "Test Suite".
Selenium IDE 14

Executing the Recorded Test

The recorded scripts can then be executed either by clicking "Play entire suite" or "Play current test" button in the toolbar.
Step 1 : The Run status can be seen in the status pane that displays the number of tests passed and failed.
Step 2 : Once a step is executed, the user can see the result in the "Log" Pane.
Step 3 : After executing each step, the background of the test step turns "Green" if passed and "Red" if failed as shown below.
Selenium IDE 15

No comments: