To create tests scripts for our web shopping app, we will need to create test data that can be sent to the user-entry forms of the user screens of the web shopping web app. We can ofcourse code test data into our test scripts using fixed values, but we would then miss out on the power of variability when running Vitaq with multiple seed runs.
Our current Vitaq test activity is focused on creating tests for our simple web shopping app, Swaglabs. The test data needed for this can easily be identified by looking at the login screen, products screen and the checkout screen.
We need to generate user input data for usernames, sortOrder, first names, last names, and postcodes.
Test data is defined in our test activity in the Activity Variables tab on the top right hand-side of your Vitaq Test Automation window. The type of test data needed for the user forms is easily identifiable by looking at the user screens and determining if it is text, integer numbers, decimal numbers or true/false selection.
If it is text, we can define a list of text values for Vitaq to choose from, so let’s start by defining the test data for the accepted usernames. We will call the Activity Variable 'userNames'. Click on the ‘down arrow’ of the Action Properties selector and select ‘from list’. Click the + button and fill in the ‘Add from List’ form with the variable name userNames, you do not need units for this variable as it is just plain text, then provide a list of possible text values for Vitaq to select from such as stardard_user, locked_out_user, problem_user, performance_glitch_user then click ok.
Remember to use the correct syntax (which follows Python coding rules). If you make a mistake then Vitaq will inform you and display a red box around the entry that is incorrect.
Please note: the units in the Activity Variables are for label purposes only. For example if you are creating an Activity Variable called length, then you will want to know what units that length is identifying, such as mm, cm, m, or km for example.
The ‘Must Have’ Activity Variables needed for our web shopping App Test Activity are: userNames, sortOrder, firstNames, lastNames and postCodes.
The only variable in this list that is not a text list is sortItems, which is a integer number for selecting the index in the drop down menu or sort items. To generate a integer number using Vitaq we need to use a Integer Number variable. Click on the Activity Variables pull down menu and select Integer Number and then click on the + button to add the variable. Fill out the form as it is shown below. This gives us a integer number with a range of 1 to 4.
Complete the list of Activity Variables as below. If you make a mistake, then double click on the Activity Variable and the edit form will pop-up for you to make changes.
You can reorder, delete and collapse the activity variable using the menu bar as shown below.
As well as weighting the automatic selection of next allowable Test Actions, Vitaq users can intelligently weight the automatic selection of Activity Variable data values.
To increase the probability of Vitaq selecting a particular element in an Activity Variable list, you need to follow the List item name with a : and then number to denote the % probability of Vitaq selecting it. It is good practice to make sure that all of your % Probability values add up to 100 and hence the % Value directly represents a portion of that 100%, as shown below.
Now we have defined the test activity diagram and activity variables, it is time to complete the WebdriverIO Spec Action scripts for Vitaq to auto-generate test data using the Activity Variables to test the web shopping App.
If you execute another await requestData(usernames) in the same Spec Action script or in another Spec Action script, Vitaq will generate a new value.
When you want to use a value from one Vitaq Spec Action code script in another Spec Action then you can use the SendDataToVitaq() and readDataFromVitaq() methods in Vitaq Library Methods for Test Data
This will disable the test action called onesie in the Vitaq test activity run.
There will be situations where once a variable has been selected it can then not be used again. To do this we can use the Vitaq library methods Vitaq Library Methods for Test Data that perform constraints on lists of items (or ranges of values). For example we can ‘allowOnlyList’ for a generation of a name from the userNames Vitaq Test Activity variable in our example web shopping app Test Activity once it has already been selected in login Spec Action script.
A full list of Vitaq library methods that provide constraints on data generation can be found in Vitaq Library Methods for Test Data
We discussed how to disable a Test Action before running a Test Activity earlier. There will be situations in which it will be useful to disable a Test Action during the running of a Test Activity, we call this dynamically disabling a Test Action. To do this we use the Vitaq method