Integration with Robot Framework (Preview)

6.0+Preview Though fully functional, the Robot Framework integration is still considered a preview feature because there are no pre-defined Robot Framework keyword libraries available for QF-Test yet so you have to create your own (which is quite easy, see below).

Introduction

Robot Framework is a very popular framework for test automation and robotic process automation (RPA). Based on Python, it comes with a plethora of ready-to-use keyword libraries for many scenarios. Most of the time the decision will be to use either QF-Test or Robot Framework, but there are situations where an integration makes perfect sense: If you have an existing infrastructure based on Robot Framework or testers with in-depth Robot Framework knowledge combined with the need for QF-Test's unique abilities in UI automation.

Prerequisites and installation

You need a current version of Python 3 installed.

If not already available, Robot Framework can be installed via pip install robotframework. Robot Framework version 4 or higher is required.

The integration requires a bridge between Python and Java. JPype serves that role very well. It needs to be installed via pip install JPype1.

QF-Test comes with a Robot Framework library called qftest that Robot Framework needs to know about. It is located in the directory .../qftest-8.0.1/ext/robotframework. You can either add that directory to your PYTHONPATH environment variable or create a file called qftest_robot.pth in the site-packages of your Python 3 installation - i.e .../python3/Lib/site-packages/qftest_robot.pth - with just one line, the full path to that directory.

Getting started

Robot Framework talks to QF-Test via its daemon mode, so you need to start QF-Test with daemon mode enabled as described in chapter 54. For test development it is best to use interactive daemon mode in which you can activate the QF-Test debugger and step through your keywords at QF-Test level in addition to using the debugger of whichever IDE you run your Robot Framework scripts from. So please start QF-Test from the command line with

qftest -daemon -daemonport 5454 -keystore=

The port 5454 is just an example, choose whatever you like, but make sure you use the same in your robot file as described below.

As explained in the documentation for the -keystore <keystore file> command line argument, -keystore= tells the daemon to use unsecured communication, which speeds up communication setup and should be OK for internal use on your local machine. The third argument to the qftest library shown below should be "false" if the QF-Test daemon is started with -keystore= and "true" otherwise.

Before creating your own Robot Framework tests with QF-Test you should try to run the demo robot script provided with QF-Test to ensure that your setup is complete. It is provided in the directory .../qftest-8.0.1/demo/robotframework. Please change to that location and run

robot carconfigSwing_en.robot

The script should launch the Swing Carconfig demo application and perform a few clicks and checks. If you run it several times you'll see another great advantage of this integration: Becaus the application is started via the QF-Test daemon its lifetime is no longer dependent on that of the Python process running the Robot Framework script. Subsequent scripts can make use of the already running application and rely on QF-Test dependencies (section 41.3) to ensure a well-defined state.

Preview SmartIDs (see section 5.6) are ideal for specifying target components in Robot Framework keyword calls. Unfortunately the leading '#' of SmartIDs introduces a comment in Robot Framework so that it would always need to be escaped which significantly reduces readability. There is a not-yet-public option in QF-Test that makes it possible to treat every 'Comment' reference automatically as a SmartID if no 'Component' node exist with that ID. Until that option becomes public it can be set at script level as shown in the procedure "use smartids without marker" in the robot.qft demo test suite:

rc.setOption(Options.OPT_SMARTID_WITHOUT_MARKER, true)

Using the library

As you can see in the file resource.txt in the Robot Framework demo directory, the qftest library should be initialized as follows:

Library    qftest    localhost    5454    false    ${SUITE}

The arguments are optional with the first three defining the host and port of the QF-Test daemon to contact and whether to use a keystore or not. The fourth one defaults to robot.qft and specifies the primary test suite from which to determine the keywords that Robot Framework can use.

Creating your own keywords

The keywords for Robot Framework are determined by parsing the primary test suite specified as argument in the Library definition of the robot script as well as all test suites included directly or indirectly from that suite.

The @keyword doctag is used to designate a 'Procedure' or an entire 'Package' hierarchy as keywords. Details are explained in section 61.2.