7. Creating test data in test action scripts¶
Passing data from and to JavaScript test action scripts to Scriptworks or Python test action scripts
Debugging Scriptworks using the Script Output tab window and Display run results in Scriptworks
Using constraints to control generation of test data values in Scriptworks
Auto-generating values for Vitaq Test Activity Variables in Python scripts
Using constraints to control generation (gen) of random test data values
7.1. Introduction¶
To create tests scripts for our bill splitting app, we will need to create test data that can be sent to the user-entry forms of the user screens of the bill splitting web app. Our current Vitaq test activity is focused on creating tests for New Accounts. The test data needed for this can easily be identified by looking at the starting user screen, the add participant and add an expense screen.
We need to generate user input data for a new account name, your name, participants name, expense item, date and amount.
7.2. Activity Variables¶
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 new account name. We will call the Activity Variable ‘new_account_title’. 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 New_Account_Title, 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 Friends, Family, Work then click ok.
Warning
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.

7.3. Activity Variable units¶
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.
7.4. Activity Variable tab¶
The ‘Must Have’ Activity Variables needed for the bill splitting web App Test Activity are: new_account_title, your_name, add_participant_name, expense_item and expense_value.
The only variable in this list that is not a text list is expense_value, which is a decimal number. To generate a decimal number using Vitaq we need to use a Real Number variable, decimal numbers require numbers to two decimal places so cannot be represented by an integer. Click on the Activity Variables pull down menu and select Real Number and then click on the + button to add the variable. Fill out the form as it is shown below. This gives us a real number with a range to be selected from of 0 to £100’s, including pence.

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.

7.5. Weighting the automatic selection of Activity Variable data¶
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.

7.6. Generating test data in test action scripts¶
Now we have defined the test activity diagram and activity variables, it is time to get complete the test action scripts for Vitaq to auto-generate test data using the Activity Variables to test the bill splitting web app.
7.7. Scriptworks test action scripts¶
The easiest way to create Selenium or Appium Test Action scripts is to use the Visual Coding capability of Scriptworks.
Make sure all of your Test Actions have the Use Language Scriptworks radio button selected as shown below.

To quickly check if your Test Action Scripts are visual scripts, look at the Test Action Scripts tab and make sure each Test Action Script listed has a (SW) for Scriptworks, on the end of its name. If they have (JS) or (PY) then they are JavaScript or Python scripts. You can mix any of these three approaches in any one Test Activity.
Then set your preferences to enable the connection with Scriptworks cloud to gain access to your project and Test Action script functions for Vitaq AI to run with Selenium.
Select Edit -> Preferences
Click Use Scriptworks Integration radio button. Then enter your Scriptworks User Name and Password and click on the Connect button. It will turn green if the login to Scriptworks cloud is successful as shown below.

Now click Load on the Scriptworks Project and select from the list of projects available to you in Scriptworks. Select the SplitMeSelenium project in Scriptworks. You also need to select the Run Settings for Selenium (or Appium) in the Preferences. We have pre-installed the Chrome driver for you in the docker container, so select Chrome.
Note
The runsettingsid number is the id number of the run settings group in Scriptworks for your current Scriptworks project.
Make sure you click ok to save the Preferences. If you have a small screen, you may find it difficult to navigate to the ok radio button. You can also use the tab to move between preference fields until you reach the ok radio button and then hit carriage return to save your preferences.
Note
Once you have Edited your preferences, these will be used each time you return to use Vitaq AI. So as long as you are using the same Test Activity, you do not need to Edit Preferences each time you start Vitaq AI. When you click on Edit -> Preferences, you will notice that the Connect button is not green. Do not be concerned. If you have the correct user Name and password set in the preferences, then Vitaq AI will connect to Scriptworks. You do not need to click on Connect again. Also do not be concerned if the Scriptworks project and/or Run Settings are not being displayed. If you have set them previously in Edit Preferences, they will be remembered and used.
Now to start creating your test action logic using the Scriptwork visual scripting capability.
You should have a Test Activity that looks something like this:

To create the empty Function blocks (that you can edit in Scriptworks to create your test action logic) in the Scriptworks Cloud (in the Scriptworks Project defined in Preferences) you can click on Edit -> create Scriptworks Functions as shown below:

Now let’s create a Selenium visual script for one of the actions needed in our SplitMe App Test Activity.
Open a another browser tab on your host computer (not using the browser in the Docker container) and go to www.scriptworks.io to login to your Scriptworks account. Click on ‘Your projects’ on the top right on the screen next to the ? icon. Navigate to the SplitMeSelenium project and click on the SplitMe_test_action_scripts test. Click on the fx icon and you should now see all of the Functions ready for editing.

Note
You can view Scriptworks visual functions inside the Docker container by double clicking on the associated Test Action in the Test Activity diagram of Vitaq AI. For example click on the New_Account Test Action in the Test Activity diagram. The first time you do this in your Vitaq AI docker session, it will open a Chrome browser and ask you to log into Scriptworks. Click to save your details in the Chrome browser. Then double click on the New_Account Action again and it will open up the Visual Script in Scriptworks for New_Account and it should look like this:

Now let’s add our first Visual code ‘block’. To test the SplitMe web app, we first need to navigate to the splitme.net website in the browser. Select the blocks icon on the left hand side of your Scriptworks window, then select Web - Browser Navigation as shown below.

Then click, hold and drag the ‘navigate to’ block (you will find it under the Navigation section) and place it into your Function under the ‘add test to log’ block. You will hear it click into place. It should look like this:

Finding the required Selenium (or Appium) commands in Scriptworks is very intuitive. They are all organised in the ‘blocks’ section in a contextual way. Those related to Web are prefixed with Web, for Mobile with - Mobile. For JavaScript code such as variables and conditionals you will see prefixed as JS - and Vitaq commands, such as getting generated data from Vitaq AI Test Activity Variables to Scriptworks functions using ‘value of vitaq param <variablename>’, you will find in the AI - section.
Now edit the <text> by clicking in the block, deleting the <text> and typing https://www.splitme.net Your Scriptworks Function block should look like this:

Note
In Scriptworks, whenever you refer to the website address, you need to make sure you have the full address e.g. https://www.splitme.net
We are now ready to run our first piece of Test Action Script from Scriptworks.
Open a terminal in your docker container.

Select the System Tools -> LX Terminal
If you type dir and hit return, you will see a number of scripts are ready for you to use.
We are going to start two clients, which are needed to run Vitaq with Scriptworks and Vitaq with Selenium.
Firstly type ./scriptworks_vitaq_client.js If you you type ./scr and hit tab, it will self complete for you
You should now see the client running like this:

Note
Console.log messages from Scriptworks are reported to the client window. To help with debug of test script execution, you can put the client into debug mode with –debug or -x
Now open another new terminal.
Then type ./selenium_server.js
This will start the Selenium server inside the container.
Note
If you want to run your own Selenium server from your host machine. Then you will need to set your Run Settings to “http://host.docker.internal:4444/wd/hub” rather than “http://localhost:4444/wd/hub”
Now go to Vitaq AI window and click the run button in the top menu banner. You will see the Test Activity run and launch a Chrome browser and load the SplitMe web app. If you click on the SW (Scriptworks) Results button on the top menu banner of Vitaq AI, it will ask you to log into Scriptworks again (One you’ve done this once for Results viewing it will remember your username and password), then click it again to take you directly to the Scriptworks logging results for this sime test.
You can now complete your scriptworks Functions needed for the SplitMe web app, by using the pre-created selectors you will find in your SplitMeSelenium project in that has been pre-loaded into your Scriptworks account. We have created the selectors for you, to save you time in learning Vitaq AI 7 Scriptworks. It is not the purpose of this tutorial to teach you Selenium Selectors. There many good tutorials available for this, including one in Scriptworks.
All Selenium (and Appium) commands related to selectors are contextually displayed when you have created the Selector you want to act on. For example if you want to wait until a web element is displayed such as Try SplitMe, you create the Selector using the Scriptworks inspector tool, then select it in the Function editor and you will see the ‘wait until trySplitMe is displayed’ block in the Synchronisation section as shown below.

Note
If you want to experiemnet with creating Selectors using the excellent Scriptworks Selector tool use the Scriptworks inspector tool. First you need to start the scriptworks-client (see getting started in https://www.scriptworks.io) in a new terminal on your host computer. This is different to the scriptworks_vitaq_client you have started running in the Docker container, which is used for connecting Vitaq to Scriptworks.
Now go back to the Function editor and click on edit New_Account. Click the ‘selector’ icon on the left menu bar and select the new Element trySplitMe. Drag and drop the ‘wait until trySplitMe is found’ block and then drag and drop the ‘click on trySplitMe’ Selenium command block into the Function visual script. Save it and go back and run Vitaq to see you you new script in action.

Warning
Remember to run the scriptworks_vitaq_client to connect Scriptworks function scripts to Vitaq Test Activity actions before trying to run your Vitaq Test Activity.
Note
All Scriptworks client logging will be displayed into the client shell window, so make sure you look here for debugging (as well as debugging Vitaq runs in the Vitaq Script output tab).
To use Vitaq Test Activity variables (explained in Creating test data in test action scripts) in your Scriptworks Test Action Scripts use the Scriptworks blocks in the section AI - Vitaq as shown below

To use the auto-generated data from a Vitaq Test Activity variables in a single Scriptworks function use the ‘value of vitaq param’ block and replace <variablename> with the exact name of the Test Activity variable. Each time the ‘value of vitaq param’ in a Test Action script is executed in a Vitaq run, new Vitaq test data is generated for that Test Activity Variable. Please note that the ‘variable’ is only accessible in the local function. If you want to generate Vitaq test data that is used across more than one function in your Scriptworks visual programming scripts, then you should use the save as global <variablename> and ‘plug-in’ the value of global <variablename> block as shown below.


To use a Vitaq method Appendix 1a: Vitaq Library Methods - JavaScript use the ‘run’ vitaq command as shown below for the set_enabled method (set_enabled)


and below for do_not_repeat method

and below for the get_previous method

7.8. JavaScript test action scripts¶
The default scripting language for Vitaq test actions is JavaScript. Each test action has an associated JavaScript file which contains the function code. When you create a test action, Vitaq will automatically create the template for a JS async function call.
1 2 | async function Add_Participant() {
}
|
The JS Test Action script can be reviewed and edited by double clicking on the test action in the diagram to open the integrated code editor. This can also be achieved by double clicking on the test action script name in the scripts tab on the left.
All the script files are stored in a folder of the same name as the test activity file in your working directory. You can edit your scripts in your favourite IDE and use version control on these code files. When Vitaq runs it will read the scripts from here each time, so any changes made will be picked up.
To access the Vitaq Test Activity variable generated data in the JavaScript test action script you need to use the requestData method as shown below:
await requestData(`new_account_title`)
Note
If you execute another await requestData(new_account_title) in the same script or in another test action script, Vitaq will generate a new value. If you want to use the same value further down the script then declare a block scope local variable to assign the requestData to as follows:
await recordCoverage("",`new_account_title`);
Note
Please note that this is a block scope local JavaScript vaiable which when declared in the test action script function are only accessible in the local function. If you want to declare variables that are used across more than one function (more than one Vitaq test action) in your JS scripts, then you need to use the as shown below.
variablesMap.set('activityVariableNewAccountTitle',await requestData(`new_account_title`));
When you want to assign this global scope activityVariableNewAccountTitle in another test action script in your Vitaq Test Activity you use variablesMap.get as follows:
let anotherNewAccountTitleValue = variablesMap.get('activityVariableNewAccountTitle');
To input Vitaq generated data into your webApp or mobileApp, we use the .sendKeys(await requestData(new_account_title) as shown in this example for the SplitMe new Account name field:
await driver.findElement(By.xpath(`//input[contains(@id,"undefined-egSummerholidays-Name")]`)).sendKeys(await requestData(`new_account_title`),webdriver.Key.RETURN);
7.9. Vitaq method in JavaScript test action scripts¶
To use a Vitaq method Appendix 1a: Vitaq Library Methods - JavaScript use the ‘run vitaq command’ as shown below in the example for the set_enabled method ( Appendix 1a: Vitaq Library Methods - JavaScript )
await runCommand('set_enabled', 'theNameOfYourTestAction, False');
await runCommand(‘set_enabled’, ‘theNameOfYourTestAction, False’);
This will dynamically disable the test action called theNameOfYourTestAction in the Vitaq test activity run.
A good use case example of this can be found in the arriva_bus_tickets example test Activity, found in the Home -> examples directory of the Docker container. In this web and mobile application, certain ticket types such as Student are only available in certain ticket zones (such as Durham University). So we use Vitaq’s ability to dynamically disable and then enable Test Actions based on the Test Action Script logic. In the ActivityStart Test Action Script logic we first disable all available ticket types of Adult, Student, Child, etc Test Actions. Then when Vitaq AI executes the Choose_ticket Test Action, it is now testing for a given region (defined in the previous Test Action Script) and hence we can dynamically enable the test Actions which are ‘allowable’ in a give ticket zone, such as Student in Durham University.
7.10. Passing data from and to JavaScript test action scripts to Scriptworks or Python test action scripts¶
Vitaq supports mixed language scripting in a single test activity diagram. JavaScript is the most popular scripting language for web front-end, Scriptworks is the poular visual coding tool and Python is a powerful and flexible language for heavy data manipulation tasks and API testing needs. To read data from your web or mobile app using JavaScript Test Action scripts and make it available for Scriptworks or python scripts you need to use the sendDataToVitaq method as follows:
await sendDataToVitaq("item_price", price);
In the above example the local scope JS variable price is assigned to the item_price Vitaq test Activity Variable which will become available to a Scriptworks or python Vitaq test action script.
There is also a corresponding readDataFromVitaq method that provides the reverse capability to pass data from Vitaq.
await readDataFromVitaq('item_price');
7.11. Using re-usable JS sub functions¶
When you want to create common JS functions that can be used across more than one Test Action Script, you need to put then into the JavaScript Functions file jsFunctions.js which you will find in the Test Actions properties of the green start (setUp) action.
1 2 3 4 5 6 7 8 9 10 | async function getItemPrice() {
await driver.wait(until.elementLocated(By.xpath('//div[@class="inventory_details_price"]')), 1000, 'Could not find Backpack element within the time specified');
const price = await driver.findElement(By.xpath('//div[@class="inventory_details_price"]')).getText();
console.log(price)
await driver.wait(until.elementLocated(By.xpath('//div[@class="inventory_details_name"]')), 1000, 'Could not find Backpack element within the time specified');
const name = await driver.findElement(By.xpath('//div[@class="inventory_details_name"]')).getText();
console.log(name)
await sendDataToVitaq("item_price", price);
await sendDataToVitaq("item_description", name);
}
|
7.12. Example JS Test Action Script for New_Account action¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | async function New_Account() {
await driver.wait(until.elementLocated(By.xpath(`//*[normalize-space(text())="Try SplitMe"]`)), 10000, 'Could not find the element within the time specified');
await driver.findElement(By.xpath(`//*[normalize-space(text())="Try SplitMe"]`)).click();
await driver.wait(until.elementLocated(By.xpath(`//*[normalize-space(text())="Web Version"]`)), 10000, 'Could not find the element within the time specified');
await driver.findElement(By.xpath(`//*[normalize-space(text())="Web Version"]`)).click();
await driver.wait(until.elementLocated(By.xpath(`//div[@class="testAccountListMore"]`)), 10000, 'Could not find the element within the time specified');
await driver.findElement(By.xpath(`//div[@class="testAccountListMore"]`)).click();
await driver.wait(until.elementLocated(By.xpath(`//*[normalize-space(text())="New account"]`)), 10000, 'Could not find the element within the time specified');
await driver.findElement(By.xpath(`//*[normalize-space(text())="New account"]`)).click();
await driver.wait(until.elementLocated(By.xpath(`//input[contains(@id,"undefined-egSummerholidays-Name")]`)), 10000, 'Could not find the element within the time specified');
await driver.findElement(By.xpath(`//input[contains(@id,"undefined-egSummerholidays-Name")]`)).click();
await driver.findElement(By.xpath(`//input[contains(@id,"undefined-egSummerholidays-Name")]`)).sendKeys(await requestData(`new_account_title`),webdriver.Key.RETURN);
// Record coverage for Test Activity Variables used in the action
await recordCoverage("",`new_account_title`);
}
|
7.13. Scriptworks Test Action Scripts¶
Vitaq supports Scriptworks visual programming to provide very easy to capture Appium and Selenium scripts by following the https://www.scriptworks.io/resources/getting-started/ guide
For each Test Action created in your Test Activity diagram you need to create a Scriptworks function fx with exactly the same name (including same case sensitivity) as the Test Action name. Vitaq can help to create empy template Scriptworks functions using Edit->Create Scriptworks Functions.

To access the Vitaq Test Activity variable generated data in Scriptworks blocks click on the section ‘AI - Vitaq (Beta)’ as shown below

To use the auto-generated data from a Vitaq Test Activity variables in a single Scriptworks function use the ‘value of vitaq param’ block and replace <variablename> with the exact name of the Test Activity variable. Each time the ‘value of vitaq param’ in a Test Action script is executed in a Vitaq run, new Vitaq test data is generated for that Test Activity Variable.
Note
Please note that the ‘value of vitaq param’ <variable> is only accessible in the local function. If you want to generate Vitaq test data into Scriptworks <variables> that are used across more than one function (more than one Vitaq test action) in your Scriptworks visual programming, then you should use the save as global <variablename> and ‘plug-in’ the value of global <variablename> block as shown below.

This is one of a list of the Vitaq library methods in Appendix 1 Appendix 1a: Vitaq Library Methods - JavaScript. If you have a quick look at Appendix 1 you will see that the Vitaq library methods are very extensive and powerful.
To use a Vitaq method Appendix 1a: Vitaq Library Methods - JavaScript use the ‘run vitaq command’ as shown below in the example for the set_enabled method (set_enabled)


and another example below for the get_previous method

7.14. Debugging Scriptworks using the Script Output tab window and Display run results in Scriptworks¶
If you now click on the Script output tab and then click on the ‘Run’ button in the menu bar, you will see the ‘script’ output of the Vitaq test activity as it executes each test action Script. Vitaq selects a next allowable test action, starting from the green Activity Start Test Action. Making intelligent selections in turn as Vitaq chooses its test action flow through the test activity based on the next allowable test action connections. As you run with different seeds you will see how Vitaq generates new test output each time you run it.

When you scroll through the Script Output log you will see that Vitaq reports when it is entering a Test Action to execute a Test Action Script stdout: Vitaq[New_Account] Running test action script for New_Account
To look into more detail of what is happening during the ‘Vitaq AI powered by Scriptworks’ run, you can display the run results history in Scriptworks as shown below.

Click on the Vitaq run date and time log that you are interested in and you will see a list of Vitaq Test Activity runs. Click on the SessionId to see the detailed list of operations that have been executed on your Software under Test. If you have a Fail in the list, then a snapshot is taken of the screen that failed. Click on the small camera icon on the right side of the line that has the fail to view the snapshot. Click on the snapshot to expand it to full screen.

7.15. Using constraints to control generation of test data values in Scriptworks¶
There will be situations in your test action script logic where you want to control the auto-generation of test data from the Vitaq Test Action Variables. For example where you want to make sure Vitaq does not generate the same test activity variable values twice in a given run. In our bill splitter app once a participant name has been added, the same name can’t be added again. To do this we can use the Vitaq library methods Appendix 1a: Vitaq Library Methods - JavaScript that perform constraints to control what Vitaq generates when it gets its value from the Test Activity Variable.
By using the do_not_repeat method on the Test Activity variable Participant_names, we can make sure that Vitaq gives unique names each time it generates.
A full list of Vitaq library methods that provide constraints can be found in Appendix 1. Appendix 1a: Vitaq Library Methods - JavaScript.
The visual code below will ‘constrain’ Vitaq to generate participant names that are not repeated.

7.16. Dynamically disabling Test Actions in Scriptworks¶
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 set_enabled(False)
When we have used up all 10 of the participant names (if that is the limit of names you have put in the test Activity variable list), we do not want Vitaq to try to add any new names, so we can put some simple logic in to disable the Add_Particpant Test action when this is the case.

To make sure our Test Action Script logic works for multiple seeds, reset the Test Action to be enabled at the end of the New_Account Test Action Script by using run vitaq command set_enabled with params Add_Participant, True
7.17. Python Test Action Scripts¶
When using Python, the Test Action Scripts are pieces of user created Python Code, that describe what you want Vitaq to do to create a test output in that Test Action. Each Test Action has its own associated Test action Script. When you run a Vitaq Test Activity, Vitaq will ‘run’ each Test Action script as its associated Test Action is selected in the Test Action flow. Vitaq Test Action Scripts are completely Python compatible, that is that anything that can be done in Python can be done in a Vitaq Test Action Script. Empty Test Action Scripts are created each time a Test Action is created and can be found on the left side of the Vitaq window as shown below.

You can re-order your Test Action scripts using the menu bar shown.
7.18. Python Test Action Script editor¶
By double clicking on a Test Action Script in the list, the Test Action Script editor window is opened and the script displayed. The editor is CodeMirror, which is a powerful code editor with many useful hot keys for editing such a Ctrl + S for Save and Alt-S for save and close: https://codemirror.net/doc/manual.html#commands
7.19. self.parent¶
When you run your Vitaq Test Activity, Vitaq creates a python program containing your Test Activity, Activity Variables and Test Action Scripts and executes it. It creates a python class for each Test Action. The Activity Start and the Activity end Test Actions are the set-up and tear-down classes for the top Test Activity parent class. So if you define a Python variable or object in one of these Test Action Scripts you only need to reference them with self for example self.count = 0
. If you want to access Python variables or objects across all of the other non-parent Test Action Scripts, you need to use self.parent to access them. These other Test Action Scripts are displayed in the Test Action Script tab indented and preceded by a ‘-‘, such as - New_Account or - My_Account
Note
For example if you type this python code into the first line of the Activity start Test Action Script self.parent.count = 0
, to initialise a python variable you have named count to 0, you could then increment the count variable in any of the other indented Test Action Scripts by typing in self.parent.count += 1
into that script.
7.20. Auto-generating values for Vitaq Test Activity Variables in Python scripts¶
The core Vitaq library for controlled-random generation of test data is accessible through Python method calls in the Test Action Scripts.
To get Vitaq to auto-generate variable values we need to call the Vitaq gen() gen in the appropriate Test Action Script.
To auto-generate data for the New_Account test action, we click on the +New_Account in the Test Scripts tab to reveal the Test Action Script. Double click on this to open the CodeMirror test script editor.
In the New_Account Test Action Script we first want to auto-generate test data for the title, your name and then account description fields. We will leave the email and currency as default for the time-being.
All Python Test Script Code that you need to enter into the Vitaq Test Script editor is shown here in red ‘code’ font and in a grey box.
The python test script Vitaq library call for this is shown below:
self.variables.new_account_title.gen()
self.variables.new_account_your_name.gen()
When-ever we want to auto-generate test data from a defined Activity Variable, we use self.variables (which is the same as self.parent)
self.variables.activity_variable_name.gen()
If we want to generate values for ALL defined Activity Variables at the same time, we use
self.variables.gen()
To find out what value Vitaq has auto-generated, we use the following python test script Vitaq library method get_value
self.variables.activity_variable_name.get_value()
We can add these methods to a python print function after the auto-generation to print to our Python Output window.
print ('Create a new account with these attributes: ',self.variables.new_account_title.get_value(),self.variables.new_account_your_name.get_value())
Your Test Action Script for New_Account should now look like this

Warning
Your MUST do File Save or Ctrl+S in the New_Account Test Action Script (TAS) to get Vitaq to use your TAS code. It is good practice to actually File Save and Close (Alt+S), otherwise when you come to edit the test action script again, you may inadvertently open another editor window with the same TAS code inside.
7.21. self.variables.TestActivityVariableName.gen()¶
To generate test data for the Add_Participant variable we need to add this piece of Test Action Script into the Add_Participant Test Action Script
self.variables.add_participant_name.gen()
print ('Particpant Name is: ',self.variables.add_particpant_name.get_value())
And then in the Add_An_Expense Test Action Script add:
self.variables.expense_item.gen()
self.variables.expense_value.gen()
print ('Expense item is: ',self.variables.expense_item.get_value(),' of value = ',self.variables.expense_value.get_value())
7.22. Debugging using the Script Output tab window¶
If you now click on the Script output tab and then click on the ‘Run’ button in the menu bar, you will see the ‘python’ output of the Vitaq test activity as it executes each test action Script. Vitaq randomly selects a next allowable test action, starting from the green Activity Start Test Action. Making intelligent selections in turn as Vitaq randomly chooses its test action flow through the test activity based on the next allowable test action connections. As you run with different seeds you will see how Vitaq generates new test output each time you run it.

When you scroll through the Script Output log you will see that Vitaq reports when it is entering a Test Action to execute a Test Action Script stdout: Vitaq[New_Account] Running test action script for New_Account
7.23. Vitaq Test Activity encountered an error¶
If your test activity does not run, the Script output tab window will help you track down the problem. You will see error text in red normally ending with VITAQ TEST ACTIVITY SCRIPT ENCOUNTERED AN ERROR as shown below.

It maybe that you have a mistake in your Python test action script. This will be reported as a stderr: message and is most likely to do with syntax such as missing a closing ) to your print statement or a ] for list definition. When you have this type of error. Python will list the problem line and test as the next line after the missing ) or ], so beware and take a look at the previous line just to check you have the correct syntax.
There is a very useful AI driven Python programming co-pilot aid called kite which helps you avoid common Python mistakes and gives hits and tips for new users https://kite.com//
We have captured some of the Vitaq test activity run errors in Appendix 2: Common Vitaq errors
7.24. Using constraints to control generation (gen) of random test data values¶
There will be situations where once a variable has been selected it can then not be used again. In our bill splitter app the account owner can’t be then added as a participant and once a participant has been added they can’t be added again. To do this we can use the Vitaq library methods Appendix 2: Common Vitaq errors that perform constraints on lists of items (or ranges of values). We can ‘disallow’ the generation of a name in add_participant_name once it has been selected in new_account_your_name. We can also disallow a Participant Name from being added twice to make sure we have a unique list of names for our test. We do this by creating a Python list, that we add the your_name and add_participant names to, each time a new value is generated by Vitaq.
A full list of Vitaq library methods that provide constraints can be found in Appendix 1. Appendix 1a: Vitaq Library Methods - JavaScript.
The code below will create the list in the New_Account Test Action Script and add the generated account owner name to it:
self.parent.disallowed_name_list = list()
self.parent.disallowed_name_list.append(self.variables.new_account_your_name.get_value())
Then in the Add_Participant test action script use the disallow constraint method, as below.
self.variables.add_participant_name.dynamic_disallow_list(self.parent.disallowed_name_list)
self.variables.add_participant_name.gen()
print ('Participant Name is: ',self.variables.add_participant_name.get_value())
self.parent.disallowed_name_list.append(self.variables.add_participant_name.get_value ())
7.25. Dynamic and Static constraints¶
In this example we used a dynamic constraint which means it will only ‘hold’ for that Test Action. If you use a static constraint ‘disallow_list’ then that constraint holds for all of the generations of that Activity Variable for the rest of the Test Activity ‘run’.
There are many types of constraint that can be applied and these are listed in the Appendix 1a: Vitaq Library Methods - JavaScript.
7.26. Dynamically disabling Test Actions¶
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 set_enabled(False)
When we have used up all of the participant names, we do not want Vitaq to try to add any new names, so we can put some simple python logic in to disable the Add_Particpant Test action when this is the case.
If len(self.parent.disallowed_name_list)==len(self.variables.add_participant_name.data):
self.set_enabled(False)
To make sure our Test Action Script logic works for multiple seeds, reset the Test Action to be enabled at the end of the New_Account Test Action Script
self.parent.Add_Participant.set_enabled(True)
7.27. Sequence of exhaustive Test Actions¶
When you want to have a Test Action to be the next allowable Test Action after an Exhaustive Test Action has completed (by using up all its Test Action Call limits) then we recommend one of these Test Activity patterns.
Please accept our appologies for these examples not following-on from the tutorial example. But given the importance if understanding these Vitaq techniques’, they have been added into the documentation. This will improve as we re-work the documentation to three separate Quick start, Tutorial and reference documentations.
Option 1: You disable the follow-on ‘next allowable test Action’ until the Exhaustive Test Action call have all completed and then once completed enable the follow-on ‘next allowable test Action’ and it will be selected by Vitaqs intelligent machine algorithm.
Here’s an example.

In the first Exhaustive Test Action Script you add:
If using JavaScript test action scripts:
variablesMap.set('test_count',0);
await runCommand(`set_enabled`,`Separate_TX_RX_tests, False`);
This will reset a test counter variable test_count that can be used for counting in other test action scripts and dynamically disable the ‘Separate_TX_RX_tests’ Test Action, so it will not get selected during the Exhaustive Action selections.
If using Scriptworks visual programming scripts:

If using Python test action scripts:
self.parent.test_count = 0
self.parent.Separate_TX_RX_tests.set_enabled(False)
In each of the Test Actions at the end of the Exhaustive sequences we need to count the Test actions executed up to the sum of the call limits. Once this is met, you dynamically enable the ‘Separate_TX_RX_tests’ Test Action, so it will get selected as the next allowable Test Action as all of the Exhaustive Test Actions selections have used up their call limits.
If using JavaScript test action scripts:
let actionCount = readDataFromVitaq('test_count');
let actionCount = actionCount + 1
variablesMap.set('test_count','actionCount');
if (actionCount == 30) {
await runCommand(`set_enabled`,`Separate_TX_RX_tests, True`);
}
If using Scriptworks visual programming scripts:

If using Python test action scripts:
self.parent.test_count += 1
print('Test Count = ', self.parent.test_count)
if self.parent.test_count == 30:
self.parent.Separate_TX_RX_tests.set_enabled(True)
Option 2: You disable and enable appropriate Test Actions in the Activity_Start Test Action script so that you get the sequencing you want.
Here’s an example.

In the Activity_Start Test Action Script you add:
If using Scriptworks test action scripts:

If using Python test action scripts:
# Disable/enable some actions so we get the sequencing we want
# This will get called at the start of each seed
self.Road_Decoration.set_enabled(False)
self.Create_Road.set_enabled(True)
Then in the Create_Road Test Action Script you add at the end of the script:
If using Scriptworks test action scripts:

If using Python test action scripts:
# Enable Environment, so that when this action completes it will be run
self.parent.Road_Decoration.set_enabled(True)
self.set_enabled(False)
Once the Create_Road Test Action is ‘Exhausted’ by reaching its calling actions limits Vitaq will then return up to the Road Test Action and the only allowable next Test Action which is now enabled is the Road_Decoration Test Action and hence it will get selected. You can implement this Test Action Script logic for all the exhaustive test Action sequences you want followed in this way.