Run UFT One tests in a Docker container

Use a UFT One Docker image to speed up UFT One maintenance and test runs.

This topic assumes some knowledge in Docker management and does not describe the Docker management steps in detail.

Available UFT One Docker images

Use UFT One Docker images to run UFT One tests in a Docker container. The images are available from https://hub.docker.com/r/functionaltesting/.

The UFT One images support the following functionality:

  • Run mobile tests using Digital Lab and UFT One automation scripts.
  • Run API tests in a Windows Docker environment.
  • Run tests on Headless Chrome using UFT One automation scripts.
  • Run API tests in a Linux Docker environment.

The following images are available with the current UFT One version:

  • The uft image is a full Windows Docker image with UFT One installed.

  • The uft_utils image is based on the uft image but also includes additional utility tools.

  • The uft_one_for_api_tests image is a Linux-based image with the UFT One Runtime Engine installed.

Advantages to using the UFT One Utility Docker image

The uft_utils image enables the following enhancements:

Simpler test running Run your UFT One tests more smoothly and easily in a Windows Docker environment using a single command.
Run multiple API tests You can now use one Docker command to run of all the API tests stored in a specified folder.
Convert run results to a JUnit report After the tests run, use the ReportConverter utility to create a JUnit report from the run results.
Use Docker images in your CI-CD pipelines Use the utility tools incorporated in the Docker image to run tests on the Docker image from your CI-CD pipelines.

The UFT One Utility Docker image is released more frequently than the uft image. For instructions on using this image, use the documentation available with the image on the Docker Hub.

Back to top

System requirements for the Windows Docker images

You can run UFT One tests in a Windows Docker container on one of the following operating systems:

  • Windows Server 2016

  • Windows 10

    Versions: 2004, 1903, 1803

Back to top

Overview: Use UFT One's Docker images

To run UFT One tests in a Docker container, you must perform the following steps, which are described in more detail below:

  1. Pull the UFT One Docker image from the Docker hub.
  2. Create a container based on that Docker image.
  3. Install a concurrent UFT One license on the container.
  4. Run your UFT One tests in the Docker containers.

You must install a UFT One license on each UFT One Docker container that you use. You can handle this in one of the following ways:

  • After installing the UFT One license, you can commit this container to a new image. Then, create all subsequent containers based on the new image, and avoid additional license installations.

  • After installing the UFT One license, use the same container for subsequent runs, stopping and starting the container as needed.

  • Use a Docker command that creates a new container, installs the concurrent license, and then runs the tests.

Back to top

Before you create UFT One Docker container

This section describes how to prepare to set up a UFT One Docker container.

Prerequisites

  1. Install and set up Docker on your computer so it can pull Docker images from the Docker Hub. This sets up your computer as a Docker host.

    Install the Docker Engine and client as described in the Microsoft documentation.

    For details on setting up Docker, see the Docker documentation.

  2. Enable hardware and software virtualization on your computer.

  3. Make sure your Docker is configured to run the right type of container.

    Right-click the Docker tray icon. If Switch to Linux containers is displayed in the menu options, your Docker is set up for Windows containers.

Pull the UFT One Docker image

To pull the UFT One Docker image, run the following command in a command window on the host computer:

docker pull <UFT One Docker image name>[:tag]

The UFT One Docker image name can be functionaltesting/uft, functionaltesting/uft_utils. or functionaltesting/uft_one_for_api_tests. Choose which image to use based on the image descriptions in Available UFT One Docker images.

[:tag] is an optional flag to add for a specific UFT One image version. By default the tag value is latest.

Back to top

Set up the Windows Docker container

This section explains how to set up the UFT One Windows Docker container:

  1. To create the Docker Windows container from the UFT Docker image you pulled, run the following command in a command window on the host computer:

    docker run -it --name <container name> <UFT One Docker image name>[:tag] "cmd.exe"

    This command creates the container and also opens a command window that belongs to the container. Use this window in the next step to install a UFT One license.

    Note: The UFT One Docker images are based on Windows Server 2016. If you use a Docker host with a different OS, you may encounter a message about OS incompatibility. Consult the Docker documentation to mitigate this issue. For example, adding
    --isolation=hyperv or -–isolation=process to the command may solve the problem.

Install a UFT One license in the Windows Docker container

UFT One's Docker image is supported for concurrent licenses only, a license being consumed from the server each time a Docker container uses UFT One.

In a command window for your Docker container, install a concurrent UFT One license on the container. For details, see Manage licenses with the command line.

Back to top

Run mobile tests in your Windows Docker container

After installing and configuring your Windows Docker container, set up the UFT One-Digital Lab integration, create a UFT One automation script, and then run the script in the Docker container.

Configure the integration

To run UFT One tests on mobile devices, make sure that Digital Lab and your applications are set up for the integration. For details, see Set up Digital Lab to integrate with UFT One.

The UFT One automation script that you create in the next step set up the connection to Digital Lab.

Create a UFT One mobile automation script

Running UFT One tests on your Docker container is done using a UFT One automation script that contains the specific steps required to run your tests in Digital Lab.

Your script should include the following parts:

  • Launch UFT One.
  • Use the DLConnection object to configure the UFT One's connection to Digital Lab.
  • Use Launch methods to start your application.
  • Run your UFT One test.
  • Close the test.
  • Close UFT One.

The following is a sample script used to run a specific test in UFT Digital Lab.

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True
qtApp.Options.DLConnection.Server = "<UFT Digital Lab server address>"
qtApp.Options.DLConnection.Port = "<UFT Digital Lab server port>"
qtApp.Options.DLConnection.Username = "<UFT Digital Lab server user name>"
qtApp.Options.DLConnection.Password = "<UFT Digital Lab server user password>"
qtApp.Options.DLConnection.UseSSL = false
qtApp.Options.DLConnection.SharedSpace = "<UFT Digital Lab server TenantID>"
qtApp.Options.DLConnection.WorkSpace = "<UFT Digital Lab server workspace ID>"
qtApp.Options.DLConnection.ShowRemoteWndOnRun = true
qtApp.Open "<UFT script path>", True
Set qtMobileLauncher = qtApp.Test.Settings.Launchers("Mobile")
qtMobileLauncher.Lab = "DigitalLab"
qtMobileLauncher.Device.OS = "<Device OS Type>"
qtMobileLauncher.Device.ID = "<Device UDID>"
Set launchApp = qtMobileLauncher.LaunchOnStart
launchApp.IsPackaged = True
launchApp.Counter = 1
qtMobileLauncher.InstallApps = true
qtMobileLauncher.RestartApps = true
qtMobileLauncher.UninstallApps = false
qtMobileLauncher.TrackCPUMetric = true
qtMobileLauncher.TrackMemoryMetric = true
qtMobileLauncher.TrackFreeMemoryMetric = true
qtMobileLauncher.TrackLogs = true
Set qtpResultsOpt = CreateObject("QuickTest.RunResultsOptions") 'create the run Results Options object
qtpResultsOpt.ResultsLocation = "<HTML report path>"
qtApp.Test.Run qtpResultsOpt ' Run the test
qtApp.Test.Close
qtApp.Quit

Note: If you copy this text for use in your automation script, make sure to replace the placeholders for the UFT Digital Lab server connection details with the values from your UFT Digital Lab server.

For more details, see:

Run the automation script in the Docker container

In a command window on the host computer, run the following command:

docker run -it --name <container-name> -v <host-directory>:<container-directory> <UFT One Docker image name>[:tag] cmd //Add [:tag] to specify a UFT image version. Default is 'latest'.

cd <container-directory>

<script-name>.vbs //Run the automation script

where:

Parameter name Description

<container-name>

The name of your Docker container. Use a unique container name to create a new container.
<host-directory>

The full path to the host directory on the machine where the automation script is stored.

This directory is mounted to the <container-directory> location on your Docker container.

<container-directory> The full path to the directory on your Docker container where the <host-directory> is mounted.
<UFT One Docker image name>

The UFT One Docker image name, functionaltesting/uft.

<script-name> The name of the UFT One automation script configured to run your UFT One tests.

Note: Include the optional [:tag] for a specific UFT One image version. By default, the tag value is latest.

Back to top

Run an API test in a Windows Docker container

Run your UFT One API test in one of the ways described below.

Prerequisites

  • Set up a UFT One Docker container as described above.
  • On the host computer, create a local directory for your API tests and store the test folders there. Docker will mount this directory to a directory in your Docker container.

Run tests in a new container

Run the tests in a new container based on an image you created with the UFT One license installed.

In a command window on the host computer run the following command:

docker run -v <host-test-directory >:<container-test-directory> --name <container-name> <image-with-licensed-uft> "<UFT_One_installdir>\bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

where:

Parameter name Description

<container-name>

The name of the Docker container to create for this run.

Use a unique container name to create a new container.

<host-test-directory>

The full path to the API test on the host computer.

This directory is mounted to the <container-test-directory> location on your Docker container.

Example: C:\DockerProject\tests\apitest, where C:\DockerProject\tests is the local directory you created for your tests and apitest is the name of the test you stored there.

Note: The test-name part of this path is case sensitive.

<image-with-licensed-uft> The image that you committed after installing the UFT One license. This image is used to generate the new container that runs your test.
<container-test-directory> The full path to the directory on your Docker container where the <host-test-directory> is mounted.
<report-directory-path>

(Optional) The path to the directory in which to store the test results. Provide a relative path, relative to the <container-test-directory>.

By default, the results are saved under the test folder, overwriting the results of any previous runs.

For example if your host test directory was C:\DockerProject\tests and the test name is apitest, the command would look like this:

docker run -v C:\DockerProject\tests\apitest:C:\tests\apitest --name apirun functionaltesting/uft:latest "C:\Program Files (x86)\OpenText\UFT One\bin\HP.ST.Fwk.InternalExecuter.exe" -test C:\tests\apitest

Run the test on an existing container

In a command window on the host computer run the following command:

docker exec -it <container-name> "<UFT_One_installdir>\bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

where:

Parameter name Description

<container-name>

The name of the existing Docker container to use for this run.

Tip: Make sure the container is running before you run this command.

<container-test-directory> The full path to the directory on your Docker container where the <host-test-directory> is mounted.
<report-directory-path>

(Optional) The path to the directory in which to store the test results. Provide a relative path, relative to the <container-test-directory>.

By default, the results are saved under the test folder, overwriting the results of any previous runs.

For example if your container name is apirun, the host test directory was C:\DockerProject\tests and the test name is apitest, the command would look like this:

docker exec -it apirun "C:\Program Files (x86)\OpenText\UFT One\bin\HP.ST.Fwk.InternalExecuter.exe" -test C:\tests\apitest -reportPath result1

Back to top

Use Jenkins to trigger an API test run in Windows Docker container

After setting up your Windows Docker container, you can use Jenkins to trigger the UFT One API test run:

  1. On the host computer, create a local directory for your API test and store the test there.

  2. Add the Docker container as an agent in Jenkins.

  3. Add a build step and select "Execute Windows batch command".

  4. In the step, insert the command to trigger the test. Do one of the following: 

    • Create a new container based on a UFT One Windows Docker image that was committed after installing a license and then run the API tests.

      docker run -v <host-test-directory >:<container-test-directory> --name <container-name> <image-with-licensed-uft> "<UFT_One_installdir>\bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

    • Create a new container based on the downloaded UFT One image, install a concurrent license on the container, and then run the API tests:

      docker run -dit --name <container-name> -v <host-test-directory >:<container-test-directory> <UFT One Docker image name>[:tag] cmd.exe /C " " <UFT_One_installdir>/bin/HP.UFT.LicenseInstall.exe" concurrent <license ID> <license version> <primary server name/address>:<port> & "<UFT_One_installdir>/bin\HP.ST.Fwk.InternalExecuter.exe" -test <container-test-directory> -reportPath <report-directory-path>

    For details on this command, see Run an API test in a Windows Docker container.

Back to top

Run web and AI-based web tests in a Windows Docker container

Running web and AI-based web tests in a Windows Docker container is supported as a technical preview.

Web and AI-based web tests in Docker can run only on Headless Chrome. This section describes how to create a UFT One automation script to run such tests on Headless Chrome in Docker.

To run web and AI-based web tests on Headless Chrome in a Docker container:

  1. Prerequisites: Set up your Windows Docker container and make sure you have performed all steps described in Prepare to run tests on Headless Chrome.

  2. Create a UFT One automation script that includes the following parts:

    • Launch UFT One.

    • Use the WebLauncher object to set the browser type.

      To run AI-based web tests, AI Object Detection must be enabled. AI Object Detection is enabled by default, but if necessary, add steps to enable them.

    • Run your UFT One test.

    • Close the test.

    • Close UFT One.

    The following is a sample script:

    Copy code
    Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
    Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
    Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
    Dim qtAutoExportResultsOpts 'As QuickTest.AutoExportReportConfigOptions ' Declare the Automatically Export Report Configuration Options object variable
    Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
    qtApp.Launch ' Start UFT
    qtApp.Visible = False ' Make the UFT application invisible
    qtApp.Open "c:\tests\Headless" '
    'Set run settings for the test
    Set qtTest = qtApp.Test
    'Set RnR setting
    qtApp.Test.Settings.Launchers("Web").Active = True
    qtApp.Test.Settings.Launchers("Web").Browser = "CHROME_HEADLESS"
    Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions"
    qtResultsOpt.ResultsLocation = "c:\tests\reports"
    qtTest.Run qtResultsOpt ' Run the test
    qtApp.Test.Close
    qtApp.Quit 
  3. In a command window on the host computer, run the following command:

    Copy code
    docker run -it --name <container-name> -v <host-directory>:<container-directory> <UFT One Docker image name>[:tag] cmd //Add [:tag] to specify a UFT image version. Default is 'latest'.
    cd <container-directory>
    <script-name>.vbs //Run the automation script

    Note:  

Back to top

Run API tests in a Linux Docker container

Running API tests in a Linux Docker container is supported as a technical preview.

Prepare the prerequisites and pull the uft_one_for_api_tests image, as described in Before you create UFT One Docker container.

Running a UFT One API test requires a concurrent license.

Run the following command to install a UFT One license and run API tests:

Copy code
docker run -it -v <host-test-directory>:<container-test-directory> functionaltesting/uft_one_for_api_tests[:tag] -test <container-test-directory> -reportPath <report-directory-path> -licenseServer <License_server_ip>:<port>

Where:

Parameter name Description

<host-test-directory>

The full path to the API test on the host computer. This directory is mounted to the container test directory.

<container-test-directory>

The full path to the directory on your Docker container where the <host-test-directory> is mounted.

Example: C:\DockerProject\tests\apitest, where C:\DockerProject\tests is the local directory you created for your tests, and apitest is the name of the test you stored there.

<report-directory-path>

(Optional) The path to the directory in which to store the test results. Provide a relative path, relative to the <container-test-directory>

By default, the results are saved under the test folder, overwriting the results of any previous runs.

<License_server_ip>:<port> The IP address and port number for your concurrent license server.

Technical preview scope

The table below describes the activities you can run in API tests on the Linux-based image:

Supported activities Unsupported activities

Date/Time

CoAP

Flow

DataBase

FTP (UFT One 24.2 and later) Calling external GUI and API tests

HTTP

File

JSON

IBM WebSphere MQ

Math

JMS
REST

Java

SOAP

MQTT

String

SAP

System variables

WebSocket

XML (UFT One 24.2 and later)

 

Miscellaneous operations

 

Back to top

See also: