Documentation

PythonScriptHandler function

PythonScriptHandler function is used to trigger python script in your test execution.

Firstly you need to write your python script under Data > Manage python scripts.

Note you have to use the name (as highlighted in the above snapshot)of the python script in your python script handler function.

Select SET command from the action dropdown and provide a variable name in Element key where output will be stored, edit parameter section and click on Form, select functions from the dropdown and select PYTHONSCRIPTHANDLER function. Provide name of the function which you have given in Data > Manage python scripts.

The output of the script will be stored in a variable (output) defined in element key section. Once you complete the step it will look as below:

In case user wants to pass some arguments in python script from the test case, we have to use below syntax to use the variables.

Syntax: ${__pythonscripthandler(pythin script name,first variable name:${value1},second variable name:${value2})} Example: ${__pythonscripthandler(test,var1:${value1},var2:${value2})}

In the above example var1 and var2 are the two arguments which has some value and we need pass these values in python script using these arguments, test is python script name and value1 and value2 are the two variables which has some data.

We need to first assign the arguments to new variables using ‘@’ sign and then we can use the new variables for subsequent use as shown below:

In the above snapshot @var1 and @var2 are the two arguments defined in the test steps in pythonscripthandler function. The value assigned to var1 and var2 will be now assigned to num1 and num2 and then it can be used subsequently.

Was this page helpful?