Test Parameters
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:
Here is the CSV file for example:
name,
phone,
Tony,
0523539924,
Josh,
0548819925,
Tiffany,
0518853395,
Original
Parameterized
We replaced "Tony" value with "${name}". ${<parameter name>}
syntax is used to define external parameters.
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:
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 name
parameter. If we would run the test as before, Oxygen will pick the first value, e.g. "Tony" 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:
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.
Last updated