Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Building Test Cases in Selenium IDE

Building test cases in Selenium IDE primary require three techniques below.

 

  • Recording

The purpose of recording is to verify that Selenium IDE can identify web objects and also to simulate the test case steps. When Selenium IDE is first opened, the record button is ON by default. If you do not want Selenium-IDE to begin recording automatically you can turn this off by going under Options > Options... and deselecting “Start recording immediately on open.” Or you can just click on the button to disable the recording.

During recording, Selenium IDE will automatically insert commands into your test case based on your actions. Typically, this will include:

  • clicking a link (use click or clickAndWait commands)
  • entering values (type command)
  • selecting options from a drop-down listbox (use select command)
  • clicking checkboxes or radio buttons (use click command)
  • Adding Verifications and Assert With the Context Menu

 

When writing test cases and executing them, we will need to check the properties of a web-page. This requires assert and verify commands. With Selenium IDE recording, go to the browser displaying your test application and right click anywhere on the page. You will see a context menu showing verify and/or assert commands.

  • Editing
Insert Command

Table View

Move your mouse cursor to the point in your test case where you want to insert the command. To do this, in the Test Case Pane, left-click on the line where you want to insert a new command. Right-click and select Insert Command; the IDE will add a blank line just ahead of the line you selected. Now use the command editing text fields to enter your new command and its parameters.

Source View

Move your mouse cursor to the point in your test case where you want to insert the command. To do this, in the Test Case Pane, left-click between the commands where you want to insert a new command, and enter the HTML tags needed to create a 3-column row containing the Command, first parameter (if one is required by the Command), and second parameter (again, if one is required to locate an element) and third parameter(again, if one is required to have a value).

<tr>
    <td>Command</td>
    <td>target (locator)</td>
    <td>Value</td>
</tr>

Insert Comment

 

User can add comments to make your test case more readable. These comments are ignored when the test case is run.Comments may also be used to add vertical white space (one or more blank lines) in your tests; just create empty comments. An empty command will cause an error during execution; an empty comment won’t.

Table View: Select the line in your test case where you want to insert the comment. Right-click and select Insert Comment. Now use the Command field to enter the comment. Your comment will appear in purple text.

 

Source View: Select the point in your test case where you want to insert the comment. Add an HTML-style comment, i.e., <!-- your comment here -->.

 Edit a Command or Comment

 Table View:

Simply select the line to be changed and edit it using the Command, Target, and Value fields.

Source View:

Since Source view provides the equivalent of a WYSIWYG (What You See is What You Get) editor, simply modify which line you wish–command, parameter, or comment.

 Opening and Saving a Test Case

 

Like most programs, there are Save and Open commands under the File menu. However, Selenium distinguishes between test cases and test suites. To save your Selenium IDE tests for later use you can either save the individual test cases, or save the test suite. If the test cases of your test suite have not been saved, you’ll be prompted to save them before saving the test suite.

When you open an existing test case or suite, Selenium IDE displays its Selenium commands in the Test Case Pane.