# 17. Appendix 1a: Vitaq Library Methods - JavaScript¶

This is a list of all of the Vitaq library methods that can be used in the Test Action Scripts

Add a weighted distribution to a range of values.

A distribution is a range of values followed by a weight. The probability of a value being selected is proportional to the weight of its distribution range divided by the sum of all weights.

So for example if we defined a Activity Variable in Vitaq Test Automation as: Now let’s add a distribution to ensure 90% of the time it is between 30 and 50 and 10% of the time it is between 50 and 100.

This would be done as follows:

`await runCommand("add_distribution", 'Expense_value, 30, 50, 90');`

`await runCommand("add_distribution", 'Expense_value, 50, 100, 10');`

Note: since weights are relative the following code would have exactly the same effect

`await runCommand("add_distribution", 'Expense_value, 30, 50, 9000');`

`await runCommand("add_distribution", 'Expense_value, 50, 100, 1000');`

So now the probability of Expense_value being in the range of 30 to 50 is 90% and the probability of Expense_value being in the range 50 to 100 is 10%

As we have only added distributions for the two specific ranges then x will only be within these ranges. If we wish to allow other values then they must be specifically allowed by assigning them a weight.

Add a weighted distribution to a single value.

Add a distribution. A distribution (add_distribution) is a range of values followed by a weight. In this case the range has a single value in it. The probability of a value being selected is proportional to the weight of its distribution range divided by the sum of all weights.

So for example if range A is given a weight of 1 and range B is given a weight of 10 then the probability of a value being selected from range B is 10 / (10 + 1) and the probability of a value being selected from range A is 1 / (10 + 1).

A value may exist in multiple ranges in which case the probability of it occurring is dependent on the weights in all of the ranges

`await runCommand("add_distribution_value", 'Expense_value, 90, 50');`

Add a dynamic weighted distribution to a range of values.

Add a dynamic distribution is just like a standard distribution (see add_distribution) except that it’s effect only lasts for one generation cycle (i.e. one requestData method call).

A distribution is a range of values followed by a weight. The probability of a value being selected is proportional to the weight of it’s distribution range divided by the sum of all weights. So for example if range A is given a weight of 1 and range B is given a weight of 10 then the probability of a value being selected from range B is 10 / (10 + 1) and the probability of a value being selected from range A is 1 / (10 + 1). A value may exist in multiple ranges in which case the probability of it occurring is dependent on the weights in all of the ranges.

`await runCommand("add_dynamic_distribution", 'Expense_value, 30, 50, 90');`

Add a dynamic weighted distribution to a value.

Add a dynamic distribution is just like a standard distribution (see add_distribution) except that it’s effect only lasts for 1 generation cycle.

`await runCommand("add_dynamic_distribution_value", 'Expense_value, 90, 50');`

## 17.5. allow_only_range¶

Allow only the passed range of values into the allowable ranges for this variable.

This Vitaq library method will remove all existing static (see Static vs Dynamic ranges) constraints applied up to this point and allow only the range of values supplied.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed of type integer` `// redefine the allowable range of values for Speed to be in the range of 30 to 50`

`await runCommand("allow_only_range", 'Speed, 30, 50');` `await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_only_range", 'Speed, 30, 50');`

`await runCommand("allow_range", 'Speed, 60, 70');`

`// The only allowable values are 30 to 50 and 60 to 70`

`await runCommand("dynamic_disallow_value", 'Speed, 70');`

`// The Speed variable value 70 is not allowed for the first random generation cycle` `// i.e. first call of the requestData method on variable Speed` `await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0)` `// Speed must not be 70, but any of the other values are allowed` `// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData method.`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.6. allow_only_value¶

Allow only the supplied value as an allowable value for this Vitaq Activity variable.

This Vitaq library method will remove all existing static (see Static vs Dynamic ranges) constraints applied up to this point and allow only the value supplied.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed of type integer` `// redefine the only allowable value for Speed to 70`

`await runCommand("allow_only_value", 'Speed, 70');`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_only_value", 'Speed, 70');`

`await runCommand("allow_value", 'Speed, 30');`

`// The only allowable values are 30 and 70` `await runCommand("dynamic_disallow_value", 'Speed, 70');`

`// The value 70 is not allowed for the first random generation cycle` `// i.e. first call of the gen() method` `await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0)` `// Speed must not be 70, but any of the other values are allowed` `// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.7. allow_only_values¶

Allow only the supplied values as an allowable value for this Vitaq Activity variable.

This Vitaq library method will remove all existing static (see Static vs Dynamic ranges) constraints applied up to this point and allow only the value supplied.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed of type integer` `// redefine the only allowable values for Speed to 70 and 80`

`await runCommand("allow_only_values", 'Speed, 70, 80');`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_only_values", 'Speed, 70, 80');`

`await runCommand("allow_values", 'Speed, 30, 40');`

`// The only allowable values are 30, 40, 70 and 80` `await runCommand("dynamic_disallow_value", 'Speed, 70');`

`// The value 70 is not allowed for the first random generation cycle` `// i.e. first call of the requestData() method` `await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0)` `// Speed must not be 70, but any of the other values are allowed` `// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.8. allow_range¶

Allow a range of values as allowable values for this Vitaq Activity variable.

Allow a range of values to be included in the set of values that may be selected by the Vitaq generator.

This effect of this Vitaq library method is cumulative. Thus repeated called to allow_range() will have the effect of increasing the number of allowable values that may be selected by the generator.

By default all possible values for a given type are allowable and therefore performing allow_range() as an initial constraint will have no effect. If the desired effect is to allow only this range and thereby remove all other values then the allow_only_range() member method should be used.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer extend the only values for Speed up to 90`

`await runCommand("allow_range", 'Speed, 71, 90');` `await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_disallow_value", 'Speed, 90');` `self.variables.Speed.dynamic.disallow_value(90)`

`// The value 90 is not allowed for the first random generation cycle` `// i.e. first call of the requestData(`Speed`) method.`

`requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed must` `// not be 70, but any of the other values are allowed`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. requestData(`Speed`) method.`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.9. allow_value¶

Allow a value into the allowable ranges of values for this Vitaq Activity variable.

Allow a value to be included in the set of values that may be selected by the Vitaq generator.

This effect of this Vitaq library method is cumulative. Thus repeated called to allow_value() will have the effect of increasing the number of allowable values that may be selected by the generator.

By default all possible values for a given type are allowable and therefore performing allow_value() as an initial constraint will have no effect. If the desired effect is to allow only this range and thereby remove all other values then the allow_only_value() member method should be used.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer extend to allow one additional ‘outlier’ value for Speed of 90`

`await runCommand("allow_value", 'Speed, 90');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_value", 'Speed, 90');`

`// The allowable values are now 30 to 70 and 90`

`await runCommand("dynamic)disallow_value", 'Speed, 90');`

`// The value 90 is not allowed for the first random generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0)` `// Speed must not be 90, but any of the other values are allowed`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData() method.`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.10. allow_values¶

Allow values into the allowable ranges of values for this Vitaq Activity variable.

Allow values to be included in the set of values that may be selected by the Vitaq generator.

This effect of this Vitaq library method is cumulative. Thus repeated called to allow_values() will have the effect of increasing the number of allowable values that may be selected by the generator.

By default all possible values for a given type are allowable and therefore performing allow_values() as an initial constraint will have no effect. If the desired effect is to allow only this range and thereby remove all other values then the allow_only_values() member method should be used.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer extend to allow two additional ‘outlier’ values for Speed of 90 and 100`

`await runCommand("allow_values", 'Speed, 90, 100');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_values", 'Speed, 90, 100');`

`// The allowable values are now 30 to 70 and 90 and 100`

`await runCommand("dynamic)disallow_value", 'Speed, 90');`

`// The value 90 is not allowed for the first random generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0)` `// Speed must not be 90, but any of the other values are allowed`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData() method.`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.11. clear_call_count¶

This will reset the call count back to the call limit (set by set_call_limit() either in the action properties or in your script ) during a current seed test run. Very useful if you want to dynamically control how many times Vitaq can execute an action during a run.

`await runCommand("clear_call_count", "Action2, False");`

Clears the call count for this Test Action Action2.

`await runCommand("clear_call_count", "Action2, True");`

Clears the call count for this test Action Action2 and all next actions in the tree below this test action.

## 17.12. clear_dynamic_ranges¶

This will remove all dynamic constraints that have been applied to this point. This might be called prior to applying a new set of dynamic constraints.

Note: It is not necessary to clear dynamic ranges after generation (call of gen()) as this is done by the generator by default. After generation of a field has been completed all of its dynamic constraints are automatically cleared

Example of how to use this method in Vitaq Test Action Script:

`await runCommand("clear_dynamic_ranges", 'Speed');`

## 17.13. createVitaqLogEntry¶

This will print a Console.log into the Vitaq Test Activity log window which can be viewed in the Tab window next to the Script Output window and also in the log file. A complete log of both output windows is saved on disk in your home directory in your docker container in /home/vitaq. They are named Vitaq_Script.log and Vitaq_Activity.log, each time VitaqAI is run in the Docker container theses logs have the logging data output of the run appended onto the appropriate log file. When you stop the Docker container, the log files are not saved. Data in a Docker container is not ‘persistent’, so you need to make sure you have saved the log data you need onto your host computer before stopping the container.

`await createVitaqLogEntry("This is a console.log message being printed into the Vitaq Test Activity log");`

## 17.14. disallow_range¶

Disallow a range values from the allowable ranges for this Vitaq Activity variable.

Disallow a range of values from being included in the set of values that may be selected by the Vitaq generator.

Each time the disallow_ranges() Vitaq library method is called, the disallowed range of values is removed from the set of allowable values. The effect is cumulative and reduces the list of allowable values.

Note: Disallowed ranges may overlap with previously disallowed ranges.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer will be reduced to values for Speed of 30 to 50`

`await runCommand("disallow_range", 'Speed, 51, 70');`

`await requestData(`Speed`);`

## 17.15. disallow_value¶

Disallow a value from the allowable ranges for this Vitaq Activity variable.

Disallow a particular of value from being included in the set of values that may be selected by the Vitaq generator.

Each time the disallow_value() Vitaq library method is called, the disallowed value is removed from the set of allowable values. The effect is cumulative and reduces the list of allowable values.

Note: If a value is removed using disallow_value() which is already excluded from the allowed set of values the excluded set remains unchanged.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 90` `// of type integer will be reduced to values for Speed of 30 to 89`

`await runCommand("disallow_value", 'Speed, 90');`

`await requestData(`Speed`);`

## 17.16. disallow_values¶

Disallow a list of values from the allowable ranges for this Vitaq Activity variable.

Disallow a list of values from being included in the set of values that may be selected by the Vitaq generator.

Each time the disallow_values() Vitaq library method is called, the disallowed values are removed from the set of allowable values. The effect is cumulative and reduces the list of allowable values.

Note: If a value is removed using disallow_values() which are already excluded from the allowed set of values the excluded set remains unchanged.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 90` `// of type integer will be reduced to values for Speed of 30 to 69 and 71 to 89.`

`await runCommand("disallow_values", 'Speed, 70, 90');`

`await requestData(`Speed`);`

## 17.17. do_not_generate¶

Set this field to not generate the Test Activity Variable defined when you use a ‘generate all variable’ method `await runCommand("gen", 'top');` where top denotes all Test Activity Variables.

`await runCommand("do_not_generate", 'Speed');`

Where Speed is the Test Activity Variable that you do not want to generate a new value for when generating all using `await runCommand("gen", 'top');`

## 17.18. do_not_repeat¶

Set this field to not reuse values.

For example if we a Test ACtivity Variable called listOfNames, with a list of names such as Bill,Bob,Claire,Karen,Monty,Pilaty,Seamus. By default a Activity Variable generation requestData() method can select any value on each and every generation cycle. By setting do_not_repeat(), each time a value is generated then that value will be removed from the list of allowable values. This means that the same value will not be selected twice.

`await runCommand("do_not_repeat", 'listOfNames, True');`

Warning: Be careful when using do_not_repeat in AI mode. The AI machine learning will determine what next data to select to acheive the coverage goals. So you need to make sure you put the `await recordCoverage("",`listOfNames`);` directly after you have requested (generated) the new data, so it can be used in the AI machine learning algorithm. If you pleace your records at the end of the script, the learning will only occur then and it may be too late.

Note: After enough generation cycles have been executed then all of the available values may be exhausted. Trying to generate when there are no available values to select will cause an exception. The user should take care of resetting the constraints if this might be a problem in their Test Activity. Note: You can also turn off the do_not_repeat on a test activity variable by using:

`await runCommand("do_not_repeat", 'listOfNames, False');`

Warning: This method is only valid with a given seed. As soon as you start a new Vitaq run with a new seed value, then Vitaq will clear all methods and start from setUp again.

## 17.19. dynamic_allow_only_list¶

A dynamic constraint only applies for a single call of the Vitaq generator requestData() method for a Test Action Script generation of this variable. Dynamically allow a user defined list of text values for this variable, removing existing allowable values. The *_list methods take a Python syntax list or dict: (Note: A dict is a Python programming term for a dictionary of text variables) A list i.e. [“dog”, “cat”, “hamster”, “rabbit”, “goldfish”] – square brackets, comma separated, strings quoted with ‘, “ or ‘’’., userlist text values may not contain a comma in the list name.

Only allow these text values to be selected by the Vitaq generator. This removes any pre-existing dynamic or static user defined lists of text values for the variable and allows only these values defined in the user list of text values. This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will generate a new value for a specific Vitaq Activity Variable (in this` `// example Expense) which has already been defined in the Activity Variables tab`

`await runCommandJSON("dynamic_allow_only_list", ['Expense', ['lunch', 'dinner', 'drink']]);`

`await requestData(`Expense`);`

Example of how to use this method with a weight in Vitaq Test Action Script:

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

`// 50% probability of selecting the text value of lunch, 20% dinner and 30% drink`

`await runCommandJSON("dynamic_allow_only_list", ['Expense', {'lunch':50, 'dinner':20, 'drink':30}]);`

`await requestData(`Expense`);`

## 17.20. dynamic_allow_only_userlist¶

A dynamic constraint only applies for a single call of the Vitaq generator gen() for a Test Action Script generation of this variable. Dynamically allow a user defined list of text variables for this variable, removing existing allowable values.

The *_userlist methods take a less formal string: (Note: A string is a programming term for a type of text variable) A comma separated list i.e. dog, cat, hamster, rabbit, goldfish – comma separated strings, userlist text values may not contain a comma in the list name.

Only allow these text values to be selected by the Vitaq generator. This removes any pre-existing dynamic or static user defined lists of text values for the variable and allows only these values defined in the user list of text values. This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will generate a new value for a specific Vitaq Activity Variable (in this` `// example Expense) which has already been defined in the Activity Variables tab`

`await runCommandJSON("dynamic_allow_only_userlist", ['Expense', '"lunch,dinner,drink"']);`

`await requestData(`Expense`);`

Example of how to use this method with a weight in Vitaq Test Action Script:

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

`// 80% probability of selecting the text value of Tram and 20% Bus`

`await runCommandJSON("dynamic_allow_only_userlist", ['Expense', '"tram:80,bus:20"']);`

`await requestData(`Expense`);`

## 17.21. dynamic_allow_list¶

A dynamic constraint only applies for a single call of the Vitaq generator gen() for a Test Action Script generation of this variable.

Dynamically allow list of text variables for this variable, add to anything that was there before, so there are the items of this new list, as well as the items of the previous list. A variable that was in the previous list and is not in the new list will still be available for selection.

This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘extended list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will add new values for a specific Vitaq Activity Variable (in this` `// example Expense) which has already been defined in the Activity Variables tab`

`await runCommandJSON("dynamic_allow_list", ['Expense', ['snack', 'breakfast']]);`

`await requestData(`Expense`);`

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

Example of how to use this method with a weight in Vitaq Test Action Script:

`// If the list that you are ‘extending’ contains weights. When adding new items` `// with weights the probability of being selected gets re-calculated as weight value` `// divided by total of all weight values. i.e. If you had 50% probability of` `// selecting the text value of lunch, 20% dinner and 30% drink, then by adding two` `// new items to the list with a :80 and :20 weight All weight probabilities are` `// divided by the new total which is 200. So, 25% lunch, 10% dinner, 15% drink,` `// 40% snack and 10% breakfast`

`await runCommandJSON("dynamic_allow_list", ['Expense', {‘snack’:80, ’breakfast’:20}])`

`await requestData(`Expense`);`

## 17.22. dynamic_allow_userlist¶

A dynamic constraint only applies for a single call of the Vitaq generator gen() for a Test Action Script generation of this variable. Dynamically allow list of text variables for this variable, add to anything that was there before, so there are the items of this new list, as well as the items of the previous list. A variable that was in the previous list and is not in the new list will still be available for selection. The *_userlist methods take a less formal string: (Note: A string is a programming term for a type of text variable) A comma separated list i.e. dog, cat, hamster, rabbit, goldfish – comma separated strings, userlist text values may not contain a comma in the list name. This will only apply to a single call of the generator in a Test Action Script and will be cleared after the gen() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘extended list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will add new values for a specific named Vitaq Activity Variable (in this` `// example Expense) which has already been defined in the Activity Variables tab`

`await runCommandJSON("dynamic_allow_only_userlist", ['Expense', '"snack,breakfast"']);`

`await requestData(`Expense`);`

Weights are used to define the probability of selecting a text value in the User list. To use weights the userlist is specified with curly brackets { } and every name needs to have a colon and a value that provides weighting.

Example of how to use this method with a weight in Vitaq Test Action Script:

`// If the list that you are ‘extending’ contains weights. When adding new items` `// with weights the probability of being selected gets re-calculated as weight value` `// divided by total of all weight values. i.e. If you had 50% probability of` `// selecting the text value of lunch, 20% dinner and 30% drink, then by adding two` `// new items to the list with a :80 and :20 weight All weight probabilities are` `// divided by the new total which is 200. So, 25% lunch, 10% dinner, 15% drink,` `// 40% snack and 10% breakfast`

`await runCommandJSON("dynamic_allow_only_userlist", ['Expense', '"snack:80,breakfast:20"']);`

`await requestData(`Expense`);`

## 17.23. dynamic_allow_only_range¶

Dynamically (see Static vs Dynamic ranges) allow a range of values as allowable values removing existing allowable values for this Vitaq Activity variable. Only allow this range of values to be included in the set of values that may be selected by the Vitaq generator. This removes the pre-existing dynamic and static ranges and allows only this range. This will only apply to a single generation cycle i.e. a single call of requestData() method and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer change the range of values for Speed to be 71 to 90`

`await runCommand("dynamic_allow__only_range", 'Speed, 71, 90');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow__only_range", 'Speed, 30, 70');`

`await runCommand("allow__only_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_allow__only_range", 'Speed, 71, 90');`

`// The values 71 to 90 are the only ones allowed for the first generation cycle` `// i.e. first call of the gen() method self.variables.Speed.gen()` `// In the following while loop, during the first loop cycle (index==0) Speed will be` `// between 71 to 90.` `// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData() method.`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.24. dynamic_allow_only_value¶

Dynamically (see Static vs Dynamic ranges) allow a value as the only allowable value removing existing allowable values for this Vitaq Activity variable. Only allow this value to be selected by the Vitaq generator. This removes the preexisting dynamic and static ranges and allows only this range. This will only apply to a single generation cycle i.e. a single call of requestData() method and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range` `// 30 to 70 of type integer change the values for Speed to 90`

`await runCommand("dynamic_allow__only_value", 'Speed, 90');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_allow__only_value", 'Speed, 90');`

```// The value 90 is the only one allowed for the first generation cycle `` ``// i.e. first call of the requestData() method```

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed will be` `// between 90.`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.25. dynamic_allow_only_values¶

Dynamically (see Static vs Dynamic ranges) allow a list of values as the only allowable values removing existing dynamic and static allowable values for this Vitaq Activity variable temporarily. Only allow these values to be selected by the Vitaq generator. This removes the preexisting dynamic and static ranges and allows only these values. This will only apply to a single generation cycle i.e. a single call of requestData() method and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range` `// 30 to 70 of type integer change the values for Speed to be 80 and 90`

`await runCommand("dynamic_allow__only_values", 'Speed, 80, 90');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_allow__only_values", 'Speed, 80, 90');`

`// The values 80 and 90 are the only values allowed for the first generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed will be` `// between either 80 or 90.` `// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.26. dynamic_allow_range¶

Dynamically (see Static vs Dynamic ranges) allow a range of values for this Activity Variable. Allow only a range of values to be selected by the Vitaq generator.

This will only apply to a single generation cycle i.e. a single call of requestData() method and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range` `// 30 to 70 of type integer change the values for Speed to be 80 and 90`

`await runCommand("dynamic_allow_range", 'Speed, 80, 90');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_allow_range", 'Speed, 80, 90');`

`// The values 80 to 90 are the only values allowed for the first generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed will` `// be between either 80 to 90.`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.27. dynamic_allow_value¶

Dynamically (see Static vs Dynamic ranges) allow a value into the allowable values for this Vitaq Activity variable.

Allow a value to be included in the set of values that may be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range` `// 30 to 70 of type integer change the values to include a Speed of 90`

`self.variables.Speed.dynamic_allow_value(90)`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 80`

`self.variables.Speed.dynamic_allow_value(90)`

`// The value 90 is allowed for the first generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed could` `// be between 30 to 80 or 90.`

`// in subsequent cycles Speed can only be between 30 and 80 as the dynamic` `// constraint is removed after the first generation cycle i.e. call of gen().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.28. dynamic_allow_values¶

Dynamically (see Static vs Dynamic) allow a list of values into the allowable values for this Vitaq Activity variable.

Allow a list of values to be included in the set of values that may be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of requestData() method and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer change the values to include a Speed of 90`

`await runCommand("dynamic_allow_values", 'Speed, 90, 100');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 80');`

`// The allowable values are now 30 to 80`

`await runCommand("dynamic_allow_values", 'Speed, 90, 100');`

`// The values 90 and 100 are added for the first generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed could` `// be between 30 to 80 or 90 or 100.`

`// in subsequent cycles Speed can only be between 30 and 80 as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.29. dynamic_disallow_list¶

Dynamically (see Static vs Dynamic) disallow a list of text values from being included in the set of values that may be selected by the Vitaq generator gen() This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field. Dynamically disallow a certain list of text variables for this Activity Variable, removing from what was there before, so there are less items of this new list than the items of the previous list.

This will only apply to a single call of the generator in a Test Action Script and will be cleared after the requestData() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘reduced list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will remove values for a specific Vitaq Activity Variable (in this` `// example Expense) which has already been defined in the Activity Variables tab`

`await runCommandJSON("dynamic_disallow_list", ['Expense', ['lunch', 'dinner']]);`

`await requestData(`Expense`);`

## 17.30. dynamic_disallow_userlist¶

The _userlist methods take a less formal string: (**Note:* A string is a programming term for a type of text variable). A comma separated list i.e. dog, cat, hamster, rabbit, goldfish. (Note: userlist text values may not contain a comma in the list name.)

Dynamically (see Static vs Dynamic) disallow a list of text values from being included in the set of values that may be selected by the Vitaq generator requestData() This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Dynamically disallow a certain list of text variables for this Activity Variable, removing from what was there before, so there are less items of this new list than the items of the previous list.

This will only apply to a single call of the generator in a Test Action Script and will be cleared after the requestData() call has been completed. This Vitaq library method will constrain the Vitaq generation gen() of new values for Vitaq Activity Variables to be values of those which are a defined in the ‘reduced list’ list when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

# This will remove values for a specific Vitaq Activity Variable (in this # example Expense) which has already been defined in the Activity Variables tab

`await runCommandJSON("dynamic_disallow_userlist", ['Expense', '"lunch,dinner"']);`

`await requestData(`Expense`);`

In this case the values in the list remove the corresponding entries in the previous list. A variable that was in the previous list and is not in the new list will still be available for selection. A variable that was in the previous list and is in the new list will be removed from selection. A value not in the previous list, but in the new list will have no effect. All of this holds for the next generation cycle of this variable only.

## 17.31. dynamic_disallow_range¶

Dynamically (see Static vs Dynamic ranges) disallow a range of values for this Activity Variable. Disallow a range of values to be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer change the values for Speed to be 30 to 59`

`await runCommand("dynamic_disallow_range", 'Speed, 60, 70');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 80');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_disallow_range", 'Speed, 60, 70');`

`// The values 71 to 90 are disallowed values for the first generation cycle` `// i.e. first call of the gen() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed will` `// be between either 30 to 70.`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of gen().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.32. dynamic_disallow_value¶

Dynamically (see Static vs Dynamic ranges) disallow a value for this Activity Variable. Disallow a value to be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `// of type integer change the values for Speed to be 30 to 59`

`await runCommand("dynamic_disallow_value", 'Speed, 70');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_disallow_value", 'Speed, 90');`

`// The value 90 is disallowed values for the first generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed will` `// be between either 30 to 89.`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of requestData().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.33. dynamic_disallow_values¶

Dynamically (see Static vs Dynamic ranges) disallow a list of values for this Activity Variable. Disallow a list of value to be selected by the Vitaq generator. This will only apply to a single generation cycle i.e. a single call of gen() and will be cleared after completion of a generation on this field.

Example of how to use this method in Vitaq Test Action Script:

`// For a variable defined in the Activity Variables Tab as Speed with range 30 to 70` `of type integer change the values for Speed to be 30 to 59`

`await runCommand("dynamic_disallow_values", 'Speed, 70, 80, 90');`

`await requestData(`Speed`);`

Note: Static constraints are always applied before dynamic constraints during the Vitaq random Variable generation process. So a dynamic allow or disallow constraint will NOT be removed by this constraint but will be still applied.

`await runCommand("allow_range", 'Speed, 30, 70');`

`await runCommand("allow_range", 'Speed, 71, 90');`

`// The allowable values are now 30 to 90`

`await runCommand("dynamic_disallow_values", 'Speed, 70, 80, 90');`

`// The values 70, 80 and 90 are disallowed values for the first generation cycle` `// i.e. first call of the requestData() method`

`await requestData(`Speed`);`

`// In the following while loop, during the first loop cycle (index==0) Speed will` `// be between either 30 to 69, 71 to 79 or 81 to 89`

`// in subsequent cycles Speed may be any of the possible values as the dynamic` `// constraint is removed after the first generation cycle i.e. call of gen().`

`let index = 0;`

`while (index <= 5) {`

`await requestData(`Speed`);`

`index++;`

`}`

## 17.34. error¶

Reports an error to std_error and throws an exception of type std::string

`await runCommand('error', 'text, "subMessage"');` error(‘text’, subMessage = false)

Parameters: text The string to be output with the error subMessage This message will be included in a higher error message therefore do not display the prefix and ERROR strings.

Note: As error reports its output to the standard error stream, messages may appear out of sync with messages sent to the standard output stream. Normally this is not an issue but if it is desirable to ensure that all output both from standard output and standard error is displayed in exactly the order that calls are made then it may be desirable to force the standard error stream to use the same stream buffer as standard output.

## 17.35. error_continue¶

Reports an error to std_error and does not throw an exception

`await runCommand('error', 'runCommands, "subMessage"');`

Parameters: runCommands The string to be output with the error subMessage This message will be included in a higher error message therefore do not display the prefix and ERROR strings.

Note: As error_continue reports its output to the standard error stream, messages may appear out of sync with messages sent to the standard output stream. Normally this is not an issue but if it is desirable to ensure that all output both from standard output and standard error is displayed in exactly the order that calls are made then it may be desirable to force the standard error stream to use the same stream buffer as standard output.

## 17.36. gen¶

This Vitaq library method will generate new values for Vitaq Activity Variables when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will generate a new value for all Vitaq Activity Variables defined in the` `// Activity Variable tab.`

`await runCommand("gen", 'top');`

`// This will generate a new value for a specific named Vitaq Activity Variable` `// (i.e. Expense_value) which is already defined in the Activity Variable tab.`

`await runCommand("gen", 'Expense_value');`

## 17.37. get_error_count¶

`await runCommand("get_error_count", 'top');`

Returns the number of errors that have been issued by error() or error_continue()

Returns: the count of errors so far

## 17.38. get_call_limit¶

Get the call limit of a particular Test Action.

`await runCommand("get_call_limit", 'MyTestAction');`

## 17.39. get_previous¶

Returns the name of the previous (or previous previous) action of a Test Activity sequence.

This method is very useful if you need to make some test Action Script decisions based on what was the previous Test Action executed.

`let previous_action_object = await runCommand(`get_previous`,`Annual, 1`);` ```// get the object of the previous Test Action that was selected in a Vitaq run before Test Action 'Annual'. If you put 2, you get previous previous etc. ``let previous_action_name = JSON.parse(previous_action_object).name;``` ```// Convert the test actoin object to a strng name that you can use in your test script logic ``console.log(String((String('Name of previous action is: ') + String(previous_action_name))));``` ``// Print out the name of the previous action in COnsole.log, so you now you have a name that you can use.

## 17.40. get_seed¶

Return the start seed for this Test Activity if used in the green Starting Action Test Script or for a specific Test Action if used in a specific Test Action Script.

Example of how to use this method in Vitaq JS Test Action Script:

`console.log('The seed value for this test run is: ', await runCommand("get_seed", 'top'));`

## 17.41. get_value¶

This Vitaq library method will get the current values for Vitaq Activity Variables when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will get a value for a specific named Vitaq Activity Variable` `// (i.e. Expense_value) which is already defined in the Activity Variable tab.`

`await runCommand("get_value", 'Expense_value');`

## 17.42. get_warning_count¶

`await runCommand("get_warning_count", 'top');`

Returns the number of warnings that have been issued by warning()

Returns: the count of warnings so far

## 17.43. implies¶

This is a special Vitaq library method for building implication constraints.

This method takes two boolean relational constraint expressions as its inputs.

The implication means that if the first expression is true then the second expression must also be true. For example:

Let’s imagine that we have 3 generatable Vitaq Activity Variables of type Integer in our Test Activity A, B, and C. The rule that we wish to specify is “if A is greater than B then C must be negative, otherwise C may be positive or negative” This might more concisely be written “A > B implies C < 0 From a constraint perspective this might break down into two separate constraints i.e. If A > B then keep(C<0); If C >= 0 then keep(A<=B); This might be simplified If LHS==true then RHS=true: If RHS==false then LHS=false:

This would then be written as a constraint in our Test Action Script as follows

Example of how to use this method in Vitaq Test Action Script:

`// implies(LHS, RHS)`

`await runCommand("implies", 'runCommands, top.TestActivityVariable_A>top.TestActivityVariable_B, top.TestActivityVariable_C<0');`

This will make sure that if TestActivityVariable_A is greater that TestActivityVariable_B when created bt requestData() method then the next requestData(TestActivityVariable_C) will be generated to be a negative number (i.e. < 0).

Another example

`await runCommand("implies", 'runCommands, top.MyTestActivityVariable>100, top.AnotherTestActivityVariable>500');`

This will make sure that if the test Activity variable ‘MyTestActivityVariable’ is > 100 when generated then ‘AnotherTestActivityVariable’ will be generated to be > 500

Since generation order can vary then either of the above constraints may need to be applied. The implies method allows us to express this relationship by writing implies(LHS, RHS);

## 17.44. keep¶

This is a special Vitaq library method for building relational constraints.

A boolean relational constraint expression may be passed as a parameter to the keep() method to effect a generation rule constraint.

This method provides the mechanism to apply relational constraints to fields. i.e. relating two or more fields so that when generated they obey these constraint rules. The parameter passed to the keep constraints must be derived from

either: the comparison of two Vitaq Activity variables of type integer.

Example of how to use this method in Vitaq Test Action Script:

`// Equality constraint. This constrains Integer_A and Integer_B to be equal when requestData(Integer_A) or requestData(Integer_B) method is called`

`await runCommand("keep", 'runCommands, top.Integer_A==top.Integer_B');`

or: the comparison of one GenField variable with a constant e.g.

Example of how to use this method in Vitaq Test Action Script:

`// Greater than constraint. This constrains Test ACtivity Variable Integer_A to be greater than 100 when requestData(Integer_A) method is called`

`await runCommand("keep", 'runCommands, top.Integer_A>100');`

Constraint example: In the following example the equality constraint constrains field A and field B to have the same value and field B to be less than field C. Irrespective of the generation order these constraints will be obeyed.

In the example whenever the Activity Variables are generated by calling it’s requestData() method, fields A, B and C will be generated such that they obey their relational constraints i.e Integer_A==Integer_B and Integer_B<Integer_C. If Integer_A, Integer_B or Integer_C are individually generated at any time i.e. by calling self.variables.Integer_A.gen() then the Vitaq generator will also maintain these constraints.

Example of how to use this method in Vitaq Test Action Script:

`await runCommand("allow_only_range", 'Integer_A, -100, 100');`

`await runCommand("allow_only_range", 'Integer_C, -100, 100');`

`await runCommand("keep", 'runCommands, top.Integer_A==top.Integer_B');`

`await runCommand("keep", 'runCommands, top.Integer_B<top.Integer_C');`

`// Non equality constraint A must not be equal to C`

`await runCommand("keep", 'runCommands, top.Integer_A!=top.Integer_C');`

Note: The above behaviour can lead to unexpected results since in the case of individual field generation the current values of the related fields will be used. So assuming Integer_A==5 and Integer_B==5 from a previous generation then if we issue Integer_A.gen() then Integer_A will be constrained to be 5 to meet the constraint keep(Integer_A==Integer_B). The way to ensure that both Integer_A and Integer_B are regenerated together would be to remove B from constraint resolution by setting it inactive using

`self.variables.Integer_B.set_active(false)`

This will cause any constraint containing B to be ignored in generation. Care must be taken using this mechanism as this may cause undesirable generation results and B should be restored active i.e.

`await runCommand("set_active", "Integer_B, True");` `// after generating A.`

```await readDataFromVitaq('item_price');
```

In the above example the data generated from the Vitaq test Activity Variable item_price can be read from Vitaq and passed to JS code in the javascript Functions.

There is also a corresponding sendDataToVitaq method that provides the reverse capability to pass data from Vitaq.

```await sendDataToVitaq("item_price", price);
```

## 17.46. recordCoverage¶

To make sure that you monitor and measure your data functional coverage for Test Activity Variables into the coverage database, you need to use the recordCoverage method in the Test Action script where you are asking VitaqAI to automatically generate the data using the requestData method.

For JavaScript you need to use the recordCoverage method like this in your script:

```await recordCoverage("",`new_account_title`);
```

Here we are recording Functional Coverage for the Vitaq Test Activity Variable new_account_title. The “”, in the round brackets is just a formatting requirement and hence nothing needs to be inserted between the “”).

Warning

If you fail to record Coverage by not including the method in your script with the apprpriate Test Activity Variable, you will not get any Coverage measured for that variable and hence the Vitaq AI algorithms will not be able to achieve 100% Coverage.

Warning

If you record Coverage for a Test ACtivity Variable before generating data using the requestData method that Vitaq AI will error but continue informing that you have not yet generated any Data to measure coverage on.

## 17.47. redirect_stderr¶

Redirect output to stderr to a file.

The filename supplied will be used for the output for error() and warning() messages rather than standard error output. Supplying a empty string will cause the output to go to stderr.

In order to suppress messages altogether then the output may be sent to “nul” for Windows.

`await runCommand("redirect_stderr", "../output/Test_GUI_003_25_0_stderr.txt");`

## 17.48. redirect_stdout¶

Redirect standard output to a file.

The filename supplied will be used for the output for info() messages rather than standard output.

In order to suppress messages altogether then the output may be sent to “nul” for Windows

`await runCommand("redirect_stdout", "../output/Test_GUI_003_25_0_stdout.txt");`

## 17.49. report_seed¶

Report seed into std_out

`await requestData(`report_seed`);`

## 17.50. requestData()¶

This Vitaq library method will generate and then return new values for Vitaq Activity Variables when called in a Test Action Script.

Example of how to use this method in Vitaq Test Action Script:

`// This will generate a new value for a specific named Vitaq Test Activity Variable` `// (i.e. Expense_value) which is already defined in the Activity Variable tab.`

`await requestData(`Expense_value`);`

## 17.51. reset_distribution¶

Remove all current distribution ranges. All distribution ranges that have been applied so far will be removed. This includes both static and dynamic distributions applied. The result will be that all values satisfying all other currently applicable range constraints will be equally likely.

Example of how to use this method in Vitaq Test Action Script:

`await runCommand("reset_distribution", 'MyTestActivityVariable');`

## 17.52. reset_error_count¶

Reset the error count.

`await runCommand("reset_error_count", 'top');`

## 17.53. reset_ranges¶

Remove all constraints, both static and dynamic. This method will remove all of the range constraints from a field, both dynamic and static and the allowable range returns to the full allowable range for the type in use.

Example of how to use this method in Vitaq Test Action Script:

`await runCommand("reset_ranges", 'myTestActivityVariable');`

## 17.54. reset_warning_count¶

Reset the warning count.

`await runCommand("reset_warning_count", 'top');`

## 17.55. sendDatatoVitaq¶

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.

## 17.56. set_active¶

Set the generation of this Activity Variable to be active (inactive) If a Vitaq Activity Variable is active then it will be used in generation. If it is inactive then it will not be generated and it will not be considered in constraints.

Example of how to use this method in Vitaq Test Action Script with an Activity Variable defined as Integer_A:

`await runCommand("set_active", "Integer_A, True");`

## 17.57. set_call_limit¶

Set the call limit of a Test Action dynamically during a Vitaq run

`await runCommand("set_call_limit", "Action_A, 99");`

## 17.58. set_continue_on_error¶

Set the continue_on_error flag, this flag controls whether a call to error() will cause the execution to stop or continue. By default this flag is false.

`await runCommand("set_continue_on_error", "runCommands, False");`

Parameters value When set true allows execution to continue when error() is called when set false an exception will be thrown when error() is called See Also get_continue_on_error(), error(), error_continue()

## 17.59. set_enabled¶

Enables the Test Action to be called or not called and hence can control the calling of next allowable Test Actions in the connected Test Action flow. Set the Test Action to be enabled/disabled in the Test Action Script. If disabled then the Test Action will not be selected and called as a next allowable Test Action.

Example of how to use this method in Vitaq Test Action Script:

`await runCommand('set_enabled', 'Add_Participant, False');`

## 17.60. set_exhaustive¶

Sets a test action to be exhaustive dynamically. If you use False then it will clear the exhaustive and set it back to a normal action.

`await runCommand('set_exhaustive', 'Integer_A, True');`

## 17.61. set_progress_on_complete¶

Progress to a possible next sequence when this sequence completes.

Progress to a possible next sequence when this sequence completes. Default is true i.e. when this sequence complete it will automatically progress to the next sequence. If false the sequence will end.

It is useful to set this false if a sequence will automatically repeat and it should only progress under certain circumstances

`await runCommand('set_progress_on_complete', 'False');`

## 17.62. set_value¶

Set a value manually for a self.variable.gen().

Set the current value for this generation field. This can be used instead of gen to set the field to a specific value. Any dynamic constraints will be cleared after execution. set_value() may set the field to a value outside of that constrained by the constraints without giving an error. This is at the users discretion.

Example of how to use this method in Vitaq Test Action Script for setting the value of Activity Variable called Speed of type integer:

`await runCommand('set_value', "Speed, 55");`