Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Selenium Essentials
  • Table Of Contents Toc
  • Feedback & Rating feedback
Selenium Essentials

Selenium Essentials

By : Sams
5 (1)
close
close
Selenium Essentials

Selenium Essentials

5 (1)
By: Sams

Overview of this book

If you are a developer who wants to migrate from Selenium RC or any other automation tool to Selenium WebDriver, then this book is for you. Knowledge of automation tools is necessary to follow the examples in this book.
Table of Contents (7 chapters)
close
close

Data Driven tests

Parameterization is a part of the Data Driven technique for retrieving values from an external data source as input. In general, the Data Driven tests are used to verify the actual and expected values from an external data source. The Selenium IDE plays a major role in parameterization, as it operates with different sets of permutations and combinations. Let's see how we can use a JavaScript file as a data source for Data Driven tests. The following is the JavaScript syntax for parameterization:

varname = "value"

For example, create a JavaScript (.js) file (Datasource.js) that includes the following keywords:

Search1 = "PrashanthSams"
Search2 = "Selenium Essentials"

Launch the Selenium IDE and choose Options… from the Option menu, Option | Options.... Now, browse through Selenium IDE extensions and select the .js file created earlier (Datasource.js), as shown in the following screenshot:

Data Driven tests

Finally, restart the Selenium IDE to effect the changes. Initialize, store, and fetch values from the .js file one by one using the storeEval command, as follows:

Data Driven tests

Here, Search1 and Search2 are the two variables that retrieve the respective keywords from the JavaScript file. These values are again stored in the new variables, GoogleSearch1 and GoogleSearch2, as shown in the preceding screenshot.

User-defined JavaScript methods

The IDE actions, accessors, and assertions can be user-defined and customized. To achieve this, the user is supposed to add JavaScript methods to the Selenium object prototype and the PageBot object prototype. In general, the Selenium IDE verifies the user-defined JavaScript methods on launching the IDE. Selenium Core extensions (user-extensions.js) in Options... give support to upload the user-defined JavaScript files.

Let's discuss this with an example that involves step-by-step instructions, as follows:

  1. Refer to the Google site https://sites.google.com/site/seleniumworks/selenium-ide-data-driven to download the following JavaScript files:
    • datadriven.js
    • goto_sel_ide.js
    • user-extensions.js
  2. Launch the Selenium IDE and choose Options… from the Option menu, Option | Options.... Now, navigate to Selenium Core extensions and upload the JavaScript files (user-extensions.js, goto_sel_ide.js and datadriven.js), as shown in the following screenshot. Finally, restart the Selenium IDE for the changes to take effect.
    User-defined JavaScript methods
  3. In the Selenium IDE, the XML file is used as a data source to store values, whereas Datadriven.js is designed to support the XML file format.

    Here is the syntax for XML file formatted data source:

    <testdata>
      <test varname="value" />
      <test varname="value" />
      <test varname="value" />
    </testdata>

    Create an XML file with the extension .xml (data.xml). Here, varname is the variable name, and value refers to the keyword under the <test> tag. Let's create an XML file with the .xml extension (data.xml). For example, refer to the following code snippet:

    <testdata>
      <test phrase="selenium essentials" />
      <test phrase="seleniumworks.com" />
      <test phrase="prashanthsams" />
    </testdata>
  4. Take a look at these details: loadTestData is a user-defined command that fetches the XML data source, while and endWhile do looping, whereas nextTestData checks for the data from the next row in the data source. The user can add any number of JavaScript methods. The following screenshot shows this step in detail:
    User-defined JavaScript methods
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Selenium Essentials
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon