Share this page

# Write tests for a UFT Developer grid

This topic explains how to write tests that can run using a UFT Developer grid. The tests specify the environment capabilities they require, and the grid finds a connected node that matches those requirements.

Supported for tests written using the UFT Developer Java or .NET SDK.

In this topic:

## Overview

A UFT Developer test that runs using a grid is made up of the following parts:

    // Describe the environment on which to run

    // Launch your application or launch a browser and navigate to the application

    // Perform operations on your application

    // Verify the operation results

Before performing any testing operations, a test must get an environment to run them on, and launch an application or browser. After that, performing operations and verifying their results is the same whether you use using a grid or not.

This section describes how to describe the environment on which to run and how to launch your application or browser on that environment.

Tip: You can design all of your tests with a statement that describes an environment. This way, you can run the tests in a grid setup whenever needed. If you want to run the same test on a standalone UFT Developer instead of a grid, you can provide an EnvironmentDescription parameter that does not specify any requirements.

## Describe an environment and launch your application

This section describes how to describe the environment on which to run and how to launch your application or browser on that environment.

1. Start your test with a statement that describes the required environment specifications:

   `DesktopEnvironment env = EnvironmentFactory.get(environmentDescription);`

   In the EnvironmentDescription, describe the environment capabilities this test requires. For details, see Build an environment description.

   EnvironmentFactory.get places a lock on a node that matches the environmentDescription, and returns an object that represents the selected environment.

   For details on these classes, see the SDK references: Java (EnvironmentFactory.get, environmentDescription) and .NET (EnvironmentFactory.get, EnvironmentDescription).

2. Use the DesktopEnvironment object retrieved in the previous step to launch your application on the node:

   - Desktop applications:

         Aut calc = env.launchAut("C:\\Windows\\System32\\calc.exe");

     Note: Make sure your node is configured to enable UFT Developer tests to launch desktop applications. For details, see Run desktop applications using the UFT Developer SDK.

   - Web applications: Launch a browser and navigate to your application.

         Browser browser = BrowserFactory.launch(browserDesc, env);
         browser.navigate("https://www.online-calculator.com");

     Note: Make sure the Micro Focus UFT Agent extension is enabled in the relevant browser. For details, see Set up web browsers and controls.

   - SAP GUI session:

         GuiSession guisession = GuiSessionFactory.launch(launchInfo, env)

   For details, see:

   Java SDK Reference | .NET SDK Reference
   --- | ---
   DesktopEnvironment | IDesktopEnvironment
   BrowserFactory.launch(BrowserDescription browserDescription, Environment env) | BrowserFactory.Launch(BrowserDescription,IEnvironment)
   BrowserFactory.launch(BrowserType browserType, Environment env) | BrowserFactory.Launch(BrowserType,IEnvironment)
   GuiSessionFactory.launch(SessionLaunchInfo launchInfo, DesktopEnvironment env) | GuiSessionFactory.Launch(SessionLaunchInfo, IDesktopEnvironment)

3. After launching your application on the requested environment, perform operations directly on the application, using the handle returned by the launch method.

If your test includes only browser operations

You can use BrowserFactory.launch statements without first requesting an environment. You can describe your environment directly in this step.

Use one of the following statements:

- `Browser browser = BrowserFactory.launch(browserDescription);`
- `Browser browser = BrowserFactory.launch(browserType);`

Provide a browserType or a simple browserDescription, in which case the grid looks for a node that has the requested browser, without checking for any other environment capabilities. Alternatively, you can add environment capabilities inside the browserDescription, describing the details of the node you want the grid to use. For details on environment capabilities, see Build an environment description.

BrowserFactory.launch runs the requested browser on a relevant node, places a lock on the node, and returns an object that represents the selected browser. You can use this object to perform operations on the launched browser.

If your test also needs to perform non-browser operations on the node, use `EnvironmentFactory.get` to request an environment. Then, use the returned environment object to launch the browser and perform other steps on the same node.

For details, see:

Java SDK Reference | .NET SDK Reference
--- | ---
browserType | BrowserType
browserDescription | BrowserDescription
BrowserFactory.launch | BrowserFactory.Launch(BrowserDescription)

Back to top

## Perform desktop operations on the node

To perform desktop operations on the same node, use the DesktopEnvironment `env` object you obtained above:

Operations | Java API | .NET API
--- | --- | ---
Access a top-level window or dialog box on the node. | env.describe(type, description) | env.Describe<type>(description)
Access the node's keyboard device to perform low-level operations. | env.getKeyboard() | env.Keyboard()
Access the node's mouse device to perform low-level operations. | env.getMouse() | env.Mouse()

Back to top

## Build an environment description

The UFT Developer grid finds a node for a test based on the node's capabilities and the test's environment description.

A node's capabilities are made up of:

- Operating system type and version, which UFT Developer detects automatically.

- Available browsers and versions, configured in the node settings. For details, see Add-in settings.

- The add-ins loaded on the node, configured in the node settings. For details, see Add-in settings.

- Additional capabilities provided by the node, that you describe in name-value pairs similar to the ones in a test's environment description. Describe these capabilities in the node settings. For details, see Custom capabilities.

- The node's name.

In your test's environment description, describe the capabilities required for this test run in name-value pairs. For operating systems and browsers, use the strings described below. For custom capabilities, use name-value pairs that match the ones you defined in the node settings (not case-sensitive). For details on the environment description class, see the Java and .NET SDK References.

Capability | Name | Value
--- | --- | ---
Operating system type | `osType` | One of: `Windows`, `Linux`, `OSX`
Operating system version | `osVersion` | The operating system version. You can describe the version using Semantic Versioning, and include conditions, such as `>` or `<` to specify "later than" or "earlier than". Note: The latest token is not supported.
Browser type | `type` | See com.hp.lft.sdk.web.BrowserType (Java) or HP.LFT.SDK.Web.BrowserType (.NET).
Browser version | `version` | The version number defined node's runtime engine settings. You can describe the version using Semantic Versioning, and include conditions, such as `>` or `<` to specify "later than" or "earlier than". Note: The latest token is not supported.
Node name | `name` | The node name defined in the node's runtime engine settings.

Tip:

- Use the Grid Management Console to see the capabilities of all the nodes currently connected to the grid.
- Use a parameterized approach for environment descriptions. This enables easier maintenance and enables each run to specify different environment requirements.

Back to top

## Modify existing tests to run on a UFT Developer grid

If you have existing tests that were not designed to run using a grid, update them to start with an environment description.

Call EnvironmentFactory.get with an environment description. The UFT Developer grid finds a node with the required capabilities, locks it, and returns an environment object. For details on this method, see the Java or .NET SDK reference.

Replace the following statements in your test with new statements that use the environment object. This specifies the environment on which to perform the steps:

Operation & Old statement | New statement (Java) | New statement (.NET)
--- | --- | ---
Launch desktop application `Desktop.launchAut` | env.launchAut(application, optional application arguments) | env.LaunchAut(application, optional application arguments)
Launch browser `BrowserFactory.launch(browserDescription)` | BrowserFactory.launch(browserDescription, env) | BrowserFactory.Launch (browserDescription, env)
Launch SAP GUI session `GuiSessionFactory.launch(<launch info parameters>)` | GuiSessionFactory.launch(launchInfo, env) | GuiSessionFactory.Launch(launchInfo, env)
Access a top-level window or dialog box on the node. `Desktop.describe(type, description)` | env.describe(type, description) | env.Describe<type>(description)
Access the node's keyboard device to perform low-level operations. `Keyboard` | env.getKeyboard() | env.Keyboard()
Access the node's mouse device to perform low-level operations. `Mouse` | env.getMouse() | env.Mouse()

Back to top

## Code samples of tests for a UFT Developer grid

You can find code samples here:

- .NET: UFT Developer Grid code samples (.NET SDK)
- Java: UFT Developer Grid code samples (Java SDK)

See also:

- UFT Developer Grid
- Configure a UFT Developer node's runtime engine settings
- EnvironmentFactory.get
- BrowserFactory

https://admhelp.microfocus.com UFT Developer 8942
Tips to improve your search results... UFT Developer Help Center UFT Developer Help 15.0-15.0.2 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: