Using Python

This topic provides guidelines for using the Beta version of Python support. You can write GUI tests in Python, while continuing to use other capabilities as you did before.

Overview

You can automate tests with Python, alongside VBScript. When you create a new GUI test, select the programming language in which you want to write the test. The processes for editing and running tests are the same for both languages.

To write effective Python tests, you need to be familiar with Python. If you are new to Python and would like to learn more, see the official Python documentation.

Back to top

Installation prerequisite

To use Python for testing, you must install the Functional Testing Python Engine with OpenText Functional Testing.

If you have a supported version of Python on your machine before installing OpenText Functional Testing from the setup.exe file, the Functional Testing Python Engine is installed automatically.

Otherwise, you can install it manually after installing Python. For details on the supported Python versions, see Support Matrix.

Note:

When you run only the .msi program that installs OpenText Functional Testing, the Functional Testing Python Engine is not installed. For details on running the installation setup.exe, see Installation wizard.

To install the Functional Testing Python Engine manually, run python_engine.msi located under <installdir>\Installation\functional_testing_python_engine\.

During the installation, the Functional Testing Python Engine is linked to the latest 32-bit Python version available on your system. If you want to use a specific version, make sure that only that version is downloaded and available on your system before starting the installation.

Upgrading Python

If you upgrade your Python version after installing the Functional Testing Python Engine, the engine remains linked to the previous version. If you want the engine to use the new Python version, or if you uninstalled the previous Python version, you must uninstall the Python Engine and install it again.

Note: this is relevant only if you are upgrading Python to a new major version (for example, from 3.11.x to 3.12.x).

Back to top

Create and run Python tests

When you create a new GUI test, select Python as the programming language.

Next, you can write your test in Python in the editor, or use built-in features to create and edit steps. For example, the Object Spy, Object Identification Center, Step Generator, Test Recorder, and Object Repository Window and Manager are all supported for working in Python.

For details on using test objects, methods, and properties in your tests, see the Object Model Reference. The examples are mostly in VBScript.

When programming in Python:

  • You can replace VBScript programming statements with Python ones, using the official Python documentation for syntax and guidelines.
  • For Object Model steps, use the demonstrated syntax, but make sure all method calls enclose the arguments in parentheses '()'. Use empty parentheses '()' when calling a method with no arguments.

Run Python GUI tests as you would run VBScript GUI tests.

Back to top

Beta feature scope

Writing tests in Python is being introduced as a Beta feature, and has the following known issues:

Area Known issue
Unsupported features

The following features are not supported:

  • Keyword View
  • Active Screen
  • Recovery scenarios
  • Business Process Testing (BPT)
  • Robotic Process Automation (RPA)
Interactive input methods

The following Python methods, which read values from standard input, are not supported:

  • input()
  • sys.stdin.read()
  • sys.stdin.readline()
  • sys.stdin.readlines()
  • fileinput.input()

Rather than writing scripts that accept input interactively, provide information to your test in other ways, such as data table parameters.

Highlighting steps as the test runs When running Python tests without inserting a breakpoint, test steps are not highlighted as the test runs.
Debugging from action

After selecting Debug from Action and clicking Run, the test run pauses at the first statement. You must click Continue to proceed and highlight subsequent statements.

Pressing Step Over does not advance to the next action and the run stays paused until you click Continue.

Error handling for run errors

If a run error occurs during a Python test run (for example, an undefined variable or an unidentified test object), you cannot run the rest of the action. You can do one of the following:

  • Click Skip Action to skip to the next action and continue the run
  • Click Stop to end the run session
Visual Studio Just-In-Time (JIT) Debugger

Issue: During a test run, when a Python script error or an internal exception occurs, the Visual Studio Just-In-Time (JIT) Debugger sometimes opens, interrupting the test run.

Workaround: Disable JIT debugging in Visual Studio.

Back to top