|Lesson #8: Using an automation harness / Working with the Python harness|
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, mod_Example.py, that includes two example user-scripted actions.
The directory looks something like this:
The file python_harness.bat (Windows), python_harness.sh (Linux), or run_mac.sh (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.
ta_main.py 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 ta_main.py 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.
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 mod_Example.py. In the subsequent lesson, you will write another action, but will create an entirely new script module to hold it.