Parameterization

Using variety of test data is crucial for a successful automation testing. Let's see how simple it's to add parameters to your test case file. All you need to do is to replace inline values with parameter names and create a CSV or XLSX file with the same name as the test case (script) file and corresponding columns with parameter names. Let's take the second step from the script we have built in "Getting Started - Desktop" tutorial and parameterize it:

Original

web.type('name=search', 'selenium');

Parameterized

web.type('name=search', '${searchTerm}');

We replaced "selenium" value with "${searchTerm}". ${<parameter name>} syntax is used to define external parameters.  

Now, let's define the CSV file:

searchTerm
selenium
testing
cloudbeat

First row defines columns for each parameter. This row must include comma separated parameter names. Parameter name can include white-space. We will save the CSV file in the same directory as our test case file as wikipedia.csv.

Now we have two files:

  • wikipedia.js
  • wikipedia.csv

All we need to do now is to use the -p switch to specify the parameters file:

oxygen -p=wikipedia.csv wikipedia.js

To use parameters when executing from within the IDE; click Settings icon and specify the parameterization CSV.

Multiple Iterations

You probably noticed that we have defined three different values under searchTerm parameter. If we would run the test as before, Oxygen will pick the first value, e.g. "selenium" and will use it in the test. Ideally we would like to iterate over multiple values. This can be done using the -i switch specifying number of iterations. For example, if we wanted to run the test three times:

oxygen -p=wikipedia.csv -i=3 --pm=seq wikipedia.js

This will run three iterations of the test, each time using the next value which will be selected either randomly or sequentially depending on the setting of --pm switch. random and seq specify random and sequential modes respectively.

Similarly, number of iterations in the IDE can be defined using the settings screen.