Share this page

# Application models

An application model is an abstraction, or model, of the application you are testing.

Application models are available with Trial and Design-type licenses.

In this topic:

## Overview

An application model is comprised of a hierarchy of test objects that correspond to the structure of the actual objects in your AUT or a specific area of the AUT.

When you create a new UFT Developer application model, two files are created:

- .tsrx . An XML representation of the application model and its objects.

  This file is created when you create the application model item or project, and is updated regularly when you add test objects to your application model (using the Object Identification Center, in the Application Model editor, or directly in the file itself).

- .tsrx.cs or .java. A file containing the code for the application model class.

  Each application model is compiled into a class that can be instantiated in your test, enabling you to access the complete test object model of your application.

  This file is generated from the .tsrx file. There are several ways to generate this file, as described in Generate application model code.

Using the application model enables you to maintain your test objects in a single location for use across your entire testing suite, and helps you write your code more quickly, without the need to write manual programmatic descriptions for each object.

Tip: Use our command line utilities for converting UFT object repositories to UFT Developer application models and UFT Developer application models to UFT object repositories.

For details, see Convert UFT object repositories to UFT Developer application models and Convert UFT Developer application models to UFT object repositories.

Back to top

## Create an application model

1. You can create an application model as a dedicated application model project or as a class within the context of an existing project.

   Note: Do not add a UFT Developer test file inside a UFT Developer application model project. The project will not compile.

   Create a new application model project

   Visual Studio | In the New Project wizard, under Visual C# > Test, select UFT Developer Application Model Project. Provide a name, location, and solution name and click OK.
   Eclipse, Spring Tool Suite, or JBoss Developer Studio | In the New Project wizard, select UFT Developer > UFT Developer Application Model Project and click Next. Maven project: Select Create as a Maven project. Click Next. Select a location for the project. Click Next. Provide the Maven artifact information, as well as a name for the project. Click Finish to create the project. Non-Maven project: Specify a project name, a package for the application model, and a location for the project. Click Next. Define the Java build settings. Click Finish to create project. UFT Developer 15.0.2 or later, Java 9 or later: When creating the project, clear the option Create module-info.java file. Otherwise, after the project is created, manually move the Micro Focus external .jar files in the Java Build Path, from Classpath to the Modulepath. For details, see Move external .jar files from Classpath to Modulepath in the Java Build Path.
   IntelliJ IDEA | Open the New Project wizard. Select Application Model and click Next. If you are creating the Application model as a Maven project, select Create as a Maven project. Click Next. Provide a name and location for the project. For a non-Maven project, provide the base package (for example, com.company) For a Maven project, provide the Maven artifact information. IntelliJ 2019.3 or later & UFT Developer 15.0.1 : The first time you create an Application Model, you must specify the file type to associate with the *.tsrx file pattern. Select XML. You only need to do this once. Click Finish to create the project. When you close the wizard, a .tsrx file is created under the src folder and a corresponding .java file is generated under appmodels. Any updates made to the .tsrx file automatically invoke a regeneration of the corresponding .java file.

   Create an application model item in an existing test project

   Visual Studio | Right-click an existing test project in your solution and select Add UFT Developer > Application Model.
   Eclipse, Spring Tool Suite, or JBoss Developer Studio | Select File > New > Other > UFT Developer Application Model Item and browse to the package in the src folder where you want to add it. The item (.tsrx) is added under the package folder and a corresponding .java file is generated under the appmodels folder.
   IntelliJ IDEA or Android Studio | In the project, select the folder under which you want to add the application model item (the source folder or any folder under it). Right-click the folder, select New > UFT Developer Application Model item, and provide a name for the item. The item (.tsrx) is added under the selected folder and a corresponding .java file is generated under the appmodels folder. The following issue occurs when working with: IntelliJ 2019.3 or later & UFT Developer 15.0.1 Android Studio 4 or later The first time you create an Application Model, you must specify the file type to associate with the *.tsrx file pattern. Select XML. You only need to do this once.

2. (Optional) Modify the Application Model root node properties.

   Name | The display name of the root node in the main Application Model window.
   Class Name | Visual Studio only. The name of the class that is generated for your application model. This is the class you use in your tests. Eclipse, Spring Tool Suite, JBoss Developer Studio, IntelliJ IDEA. the application model .tsrx file acts as the application model class name. . To change the application model class name, rename the .tsrx file.
   Description | A description of the application or application area this model represents, or any other detail you want to provide.

Back to top

## Define test objects manually in the Application Model editor

You can manually define test objects in the Application Model. This is useful if you want to begin preparing your testing infrastructure before or while the application is being developed.

1. Ensure that UFT Developer is enabled.

2. Create or open an application model.

3. In the Application Model editor toolbar, click the Create new test object button and provide the required details in the New Object pane. The code name is the name that you use to reference the object in your test code.

   You can also optionally provide a detailed description and upload a screen capture image.

   Note: You can create test objects in your application model for any technology object interface provided in the UFT Developer SDK, except IBrowser (C#) or Browser (Java). When working with Web-based applications, your IBrowser / Browser test object must be created in your test code and passed to the application model class instance as the context for the application model. For more information, see About the test object hierarchy in the application model.

4. In the Identification section, click All (displayed by default) to view the supported properties for the object type you selected.

5. Select the check boxes of the properties you want to use to uniquely identify your object, and enter the relevant values for each. After you select a set of properties, you can view them together in the Used view.

   To view the recommended properties for a test object and to see the current values of those properties for the object in your application, use the Object Identification Center (OIC).

   To enter regular expression values for string properties, click the Set as RegEx star to the right of the value box.

   - Specify regular expressions using VBScript regular expression syntax. For example, to indicate any number of characters in a string, use .* and not just the * expression.

   - Regular expressions are not supported for Mobile test objects.

6. Click the Save button at the top of the New Object pane to save your changes and add the new object to the Application Model.

   Note for Eclipse, Spring Tool Suite, or JBoss Developer Studio users on Mac: To save your changes using Command+S you must move the focus outside of the Application Model editor.

Back to top

## Add test objects to the application model using the Object Identification Center

Use the Object Identification Center (OIC) to add objects to your application model. For details, see Add objects to your application model.

Back to top

## Use application model test objects in your test steps

Follow the instructions for using application model test objects in your test steps.

Visual Studio

1. Compile your application model project or the test project containing your application model.

2. If your application model is in a dedicated application model project, create a reference in your testing project to the application model DLL and add a using statement for the application model project. For example:

   using UFTDeveloperAppModelProject4;

3. For Web, SAP GUI, or Mobile applications, or optionally for Windows-based applications: Define the parent application object that your instance of the application model will use.

   For example:

   IBrowser testBrowser = BrowserFactory.Launch(BrowserType.Chrome);

   or

   IWindow myWinApp = Desktop.Describe<IWindow>(new WindowDescription {IsChildWindow = false, WindowClassRegExp = @"CalcFrame"});

4. Instantiate the application model class.

   If you defined the parent object in your code, provide the relevant parent object as the class constructor.

   For example:

   hpSite_AppModel hpSiteApp = new hpSite_AppModel(testBrowser);

   If your application model contains the parent object (for Windows-based objects), instantiate the application model class without a constructor.

   For example:

   myWinApp_AppModel App = new myWinApp_AppModel();

5. Use test objects from the application model in your tests.

   For example:

   hpSiteApp.HPMainPage.TwitterLink.Click();

Example: The following image shows a UFT Developer NUnit test in Visual Studio that references the hpSite_AppModel.

If you type the application model test object path manually, IntelliSense provides the available test objects at each level of the hierarchy.

Alternatively, you can right-click any test object in the Application Model editor, select Generate code to clipboard, and paste the generated test object code into your test.

Eclipse, Spring Tool Suite, or JBoss Developer Studio

1. Add the application model to the Java build path of your test.

2. In your UFT Developer test, add an import line for your application model.

   For example:

   `import com.hp.lft.MyAppModel;`

3. For Web, SAP GUI, or Mobile applications, or optionally for Windows-based applications: Define the parent application object that your instance of the application model will use.

   For example:

   Browser browser = BrowserFactory.launch(BrowserType.CHROME);

   or

   Window notepadWindow = Desktop.describe(Window.class, new WindowDescription.Builder().windowClassRegExp("Notepad").windowTitleRegExp(" Notepad").build());

4. Instantiate the application model class.

   If you defined the parent object in your code, provide the relevant parent object as the class constructor.

   For example:

       hpSite appModel = new hpSite(browser);

   If your application model contains the parent object (for Windows-based objects), instantiate the application model class without a constructor.

   For example:

   myWinApp appModel = new myWinApp();

5. Use test objects from the application model in your tests.

   For example:

   appModel.HPHomePage().LaptopsLink().click();

Example: The following image shows a UFT Developer JUnit test in Eclipse that references the hpSite application model.

If you type the application model test object path manually in your test, IntelliSense provides the available test objects at each level of the hierarchy.

Alternatively, you can right-click any test object in the Application Model editor, select Generate code to clipboard, and paste the generated test object code into your test.

IntelliJ IDEA

1. Add the application model to the Java build path of your test.

2. In your UFT Developer test, add an import line for your application model.

   For example:

   `import com.hp.lft.MyAppModel;`

3. For Web, SAP GUI, or Mobile applications, or optionally for Windows-based applications: Define the parent application object that your instance of the application model will use.

   For example:

   Browser browser = BrowserFactory.launch(BrowserType.CHROME);

   or

   Window notepadWindow = Desktop.describe(Window.class, new WindowDescription.Builder().windowClassRegExp("Notepad").windowTitleRegExp(" Notepad").build());

4. Instantiate the application model class.

   If you defined the parent object in your code, provide the relevant parent object as the class constructor.

   For example:

   MyAppModel.appModel = new MyAppModel(browser);

   If your application model contains the parent object (for Windows-based objects), instantiate the application model class without a constructor.

   For example:

       MyAppModel appModel = new MyAppModel();

5. Use test objects from the application model in your tests.

   For example:

   appModel.Page().Button();

The image below shows an example of a UFT Developer JUnit test in IntelliJ IDEA that references the MyAppModel application model:

If you type the application model test object path manually in your test, IntelliSense provides the available test objects at each level of the hierarchy.

Alternatively, you can right-click any test object in the Application Model editor and select Generate code to clipboard. Then you can paste the test object code into your test.

Back to top

## Manage large application models

When you have a large number of test objects in your application model, it can be difficult to find the object you need, or to check whether an object already exists just by skimming. You can use the following functionalities:

Feature | Details
--- | ---
Tags | You can add tags to test objects to categorize them. You can then filter your test objects by tag using the Advanced Search. When you add test objects from the OIC, you can create tags for the object before you add it.
Search | You can search for objects in the Search box, or click the Advanced button to filter by object name, code name, object type, properties, or tags. The search is not case sensitive.
Locate using the OIC | If you are not sure whether a test object already exists in your application model, open the OIC from the Application Model editor. Spy on the relevant object in your application and then use the Locate Object in Application Model button. You may need to switch to Edit mode and adjust the selected objects in the hierarchy or the selected properties to match the test object as it was saved in your application model.

Back to top

## Application Model editor functionality

Switch between the Application Model editor and the XML code

Visual Studio | Right-click the Application Model .tsrx file in the Solution Explorer and select View Code or View Designer. Note: In some cases, the `F7` and `Shift-F7` shortcut keys do not work.
Eclipse, Spring Tool Suite, or JBoss Developer Studio | Use the Design and Source tabs at the bottom of the .tsrx window.
IntelliJ IDEA | Use the Designer and Text tabs at the bottom of the .tsrx window.

- You can edit the application model in the editor or in the XML file. The other display is updated when you save the file.

- If you modified the application model (whether inside your IDE or in an external editor) and the changes were not synchronized to the generated code, refresh the project, open the application model inside your IDE, and rebuild the project.

- Eclipse, Spring Tool Suite, or JBoss Developer Studio users on Mac: To save your changes using Command+S you must move the focus outside of the Application Model editor.

Other Application Model editor functionality

- Highlight the object in your application that corresponds to your test object, to check that UFT Developer identifies it as expected. Before you click the Highlight button, make sure your application is open and is displaying the object you want to highlight.

  If more than one browser (including mobile browsers), UFT Mobile remote access window, or SAP GUI session window is open the first time you select to highlight a Web-based, Mobile, or SAP GUI object during an application model session, a small window prompts you to select the target application for the highlight. That window is saved as the target application for the remainder of the UFT Developer session.

  If you want to highlight objects in a different window, use the pull-down arrow next to the Highlight button and select Change to open the target application window.

- Perform basic editing options such as Copy, cut, paste, delete, undo/redo, as well as the option to drag and drop test objects within the Application Model.

- Add Visual Relation Identifiers to your test object descriptions. For details, see Use Visual Relation Identifiers (VRIs).

- Edit application models via the XML file.

- Set the color theme to light or dark:

  Visual Studio / IntelliJ IDEA | The application model inherits the color theme defined in Visual Studio.
  Eclipse, Spring Tool Suite, or JBoss Developer Studio | In a text editor, open Win: %localappdata%\LeanFT\Preferences\EclipsePluginPreferences.json Linux: ~/.leanft/preferences/EclipsePluginPreferences.json Mac: ~/Library/Application Support/LeanFT/Preferences/EclipsePluginPreferences.json In the line below, set the theme as `"LIGHT"` or `"DARK"`: `{"disablePlugin":false, "theme": "LIGHT"}`

Back to top

See also:

- About the test object hierarchy in the application model
- Generate application model code

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: