Developing your own User-scripted Python harness action

To created a scripted Python action, you must define the action, and modify the existing harness files to implement it.

The folder C:\Program Files\LogiGear\TestArchitect\harness samples\python (Windows), /Applications/TestArchitect/harness_samples/python (macOS), or /usr/local/testarchitect/harness_samples/python (Linux), in the TestArchitect program folder, holds files that act as the entry point for the Python harness. It also has one file,, that includes two example user-scripted actions.

The directory looks something like this:

The file python_harness.bat (Windows), (Linux), or (macOS) is a simple startup script. It first sets the PYTHONPATH variable to the lib/python subfolder in TestArchitect's program folder; this tells the harness code where to find the Python implementation of the automation library. The files in this folder must be imported by your Python scripts to allow them to access the library's classes and functions. is the startup Python script. Running this file executes the main() function, which sets the actions and starts the interpretation.

Your action definitions in Python may be grouped into separate modules, each of which is a .py file; it is in that the appropriate module for a given action is invoked. When a given action definition is requested by the interpreter, ta_main’s DivertToModule() function passes execution to the module in which that definition exists.

At present, only a single module,, exists in your harness samples/python directory (assuming you have a fresh installation of TestArchitect). It contains the Python code to define two actions:

The convention is to organize user-scripted functions into multiple script module files, with the name of each such file prefixed with the string "mod_". If you add new actions, you may want to do so in new script files, depending on whether or not the actions logically fit within an existing module.

In this lesson you will write an action and add it to module In the subsequent lesson, you will write another action, but will create an entirely new script module to hold it.

As a rule, adding a new action to an existing module in the Python harness involves these steps:
  1. Add a line to the list of SetActions() function calls, declaring the action for the TestArchitect interpreter.
  2. Add an else-if clause to the divert() function, directing control to a function written to handle the new action. (In the next exercise, you will divert the hello action to a Python function called action_hello.)
  3. Create a function definition that provides the actual action-specific logic. (You will write the Python code for action_hello(), which will do the actual work for the hello action.)