Selenium TestNG tests

Create a Selenium TestNG cloud runner to integrate your Selenium tests with MBT.

Overview

Creating a Selenium TestNG cloud runner involves the following steps:

  • Adapt your Selenium (TestNG) code for MBT.
  • Create a cloud runner.

  • Upload the Selenium Jar file to your Git storage or Execution storage.

Prerequisite: Selenium tests run using Digital Lab's Browser lab. Make sure you have a Digital Lab license. For more details, see Browser lab in the Digital Lab Help Center. Only the latest Chrome version is supported.

Back to top

Adapt Selenium (TestNG) code

The following adaptations need to be made to make the code suitable for use with MBT:

  • Use small, reusable @test methods. The @test methods will be converted into model units.

  • Define static RemoteWebDriver, and static WebDriverWait for each class using the driver.

  • Avoid inheritance for driver definitions. Each derived class should contain driver definitions.

  • For better component discovery, maximize the AUT window with driver.manage().window().maximize().

  • Reflect MBT parameters in your @Test methods using @Parameters. Ensure parameters are added before the discovery process.

  • Export the Selenium code to a Jar file.

Back to top

Create a cloud runner

Use the following procedure to create a Selenium TestNG cloud runner.

  1. Open the Settings menu , click Spaces, and select a workspace.

  2. Select the DevOps tab.

  3. Open the Test Runners section and click + Cloud Runner.

  4. In the Add Cloud Runner dialog box, fill in the following details:

    Field Details
    Framework

    Select one of the following frameworks:

    • MBT (Selenium TestNG): Creates MBT units.

    • Selenium (TestNG): Creates automated tests.

    Storage

    Select one of the following storage options:

    • Git: To upload the Jar file to a private or public Git repository.

    • Execution Storage: To upload the Jar file to a secured location in AWS using a Jenkins job or API requests. For details, see Upload a Jar file (Execution storage).

    Package path

    Enter at least one package to scan. You can specify up to three packages.

    The package is the location of the Selenium tests in the Jar file.

    MBT units will be created from the @test method in the package.

    URL For Git storage, enter the Git path to the Jar file.
  5. Click Save.

Back to top

Upload a Jar file (Execution storage)

Use the following procedure to upload a Jar file to Execution storage.

Note: You can incorporate the procedure below in a CI pipeline, enabling automatic upload of each built Jar file to the storage.

Prerequisite: Create an API access key with the CI/CD role. For details, see the OpenText Core Software Delivery Platform Help Center.

To upload the Jar file:

  1. Log in using the sign_in API.

    For details, see the API section of the OpenText Core Software Delivery Platform Help Center.

  2. Obtain a pre-signed URL using the presigned_url API: 

    http[s]://<server>:<port>/api/shared_spaces/<space_id>/workspaces/<workspace_id>/presigned_url?runner_id=<runner_id>&filename=<filename>&fileversion=<file version>

  3. Upload the Jar file using the following command:

    curl -X PUT -T "testProject-1.0-SNAPSHOT.jar"

    -H "Content-Type: application/java-archive"

    -H "x-amz-meta-uploadby:<API_key_name>"

    -H "x-amz-meta-fileversion:<file version>"

    https://ftc-execution-stable-dev-artifactory-external.s3.eu-central-1.amazonaws.com/89adbf30-8a63-49a2-b63f-56c22faa1bb3/1001/project.jar?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20240729T120022Z&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-meta-fileversion%3Bx-amz-meta-uploadby&X-Amz-Expires=300&X-Amz-Credential=AKIA3I5CZ32FUGYR7P7S%2F20240729%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Signature=a4464efca7651de6ba955b5a7eda84a80c26f5f042c4fc01d16d760d8d5bd2e4

Back to top

Track file uploads

You can follow the progress of Jar file uploads for Selenium test runners, and see which version is currently in use.

To track file uploads:

  1. Open the Settings menu , click Spaces, and select a workspace.

  2. Select the DevOps tab.

  3. Open the Test Runners section and select a Selenium test runner with Execution storage.

  4. Click the Upload tracker button .

    The Uploads tracker dialog box displays the upload progress of the Jar files. A label indicates which Jar file is currently active for the test runner.

Back to top