Mainframe3270 is a library for Robot Framework based on the py3270 project, a Python interface to x3270, an IBM 3270 terminal emulator. It provides an API to a x3270 or s3270 subprocess.
To use this library, you must have the x3270 project installed and included in your PATH. On Windows, you can install wc3270 and add "C:\Program Files\wc3270" to your PATH in the Environment Variables.
The library allows you to have multiple sessions open at the same time. Each session opened by Open Connection or Open Connection From Session File will return an index that can be used to reference it when switching between connections using the Switch Connection keyword. The indices start from 1 and are incremented by each newly opened connection. Calling Close All Connection will reset the index counter to 1.
Additionally, you can provide aliases to your sessions when opening a connection, and switch the connection using that alias instead of the index.
It is worth noting that the connection that was opened last is always the current connection.
By default, the library uses the emulator model 2, which is 24 rows by 80 columns. You can, however, change the model globally when importing the library with the model argument set to the model of your choice.
The basic models are 2, 3, 4, and 5. These models differ in their screen size as illustrated in this table:
They can be combined with the 3278 (monochrome green-screen) or 3279 (color) prefix, e.g. 3278-2 or 3279-2.
In addition to that, there is a -E suffix that indicates support for the x3270 extended data stream.
You can find more information on emulator models on the x3270 wiki.
In addition to setting the model globally, you can also set the model on the individual emulator basis by providing the model arguments to the Open Connection or Open Connection From Session File keywords.
Here is an example for setting the emulator in the Open Connection keyword:
And this is how you would set the emulator model in the Open Connection From Session File keyword:
Where the content of the session file would be
Note that this is an experimental feature, so not all models might work as expected.
By default the emulator visibility is set to visible=True. In this case test cases are executed using wc3270 (Windows) or x3270 (Linux/MacOSX). You can change this by setting visible=False. Then test cases are run using ws3720 (Windows) or s3270 (Linux/MacOS). This is useful when test cases are run in a CI/CD-pipeline and there is no need for a graphical user interface.
Timeout, waits and screenshot folder are set on library import as shown above. However, they can be changed during runtime. To modify the
wait_time, see Change Wait Time, to modify the
img_folder, see Set Screenshot Folder, and to modify the
timeout, see the Change Timeout keyword. Timeouts support all available Robot Framework time formats.
By default, Mainframe3270 will take a screenshot on failure. You can overwrite this to run any other keyword by setting the
run_on_failure_keyword option. If you pass
None to this argument, no keyword will be run. To change the
run_on_failure_keyword during runtime, see Register Run On Failure Keyword.