Generate application model code

This topic includes information on the different ways to generate application model code.

Methods for generating the code file

Application models include two types of files: an XML file (.tsrx) and a code file (.tsrx.cs or .java). The code file is generated from the XML file. For details, see Overview.

The code file can be generated in the following ways:

  • The UFT Developer IDE plugin automatically generates the code file when the UFT Developer project is opened in the IDE.
  • Using a command line tool. This method is recommended when you want to generate the code file or multiple code files without opening your UFT Developer projects. For details, see AppModel code generation tool.
  • For Maven-based projects, we recommend that you use the Maven plugin (Mojo). Use this method to automatically generate the code when the project is built. For details, see Maven application model generator plugin.

Back to top

AppModel code generation tool

Use the AppModel code generation tool to generate the application model code files. This is a useful method when you upgrade UFT Developer, especially, when dealing with multiple files. For details, see Upgrade UFT Developer.

There are two tools: one for Java and one for C#. Use the one relevant for your project.

Run the tool for every project that includes an application model.

You can run the tool in one of the following modes:

  • Single file mode. Generates a single application model from a single .tsrx file.
  • Source folder mode. Generates application models for all .tsrx files under the Source folder.

To run the Java tool


Windows: <UFT_Developer_installdir>\Tools\AppModelCodeGenerator\Java\

Linux/Mac: <UFT_Developer_installdir>/Tools/appmodel-code-generator/Java

Single file mode format:

java -jar appmodel-code-generator.jar <tsrx path> -package <package name> -outputDir <output directory> -inPlace -sdk <sdk standalone jar>

Source folder mode format: 

java -jar appmodel-code-generator.jar <Source folder path> -outputDir <output directory> -inPlace -sdk <sdk standalone jar>

To run the C# tool


Windows: <UFT_Developer_installdir>\Tools\AppModelCodeGenerator\DotNet\

Single file mode format:

AppModelCodeGenerator.exe <tsrx path> -namespace <namespace name> -outputDir <output directory> -inPlace -sdk <sdk dll>

Source folder mode format: 

AppModelCodeGenerator.exe <Source folder path> -namespace <namespace name> -inPlace -outputDir <output directory> -sdk <sdk dll>

Back to top

Maven application model generator plugin

The Maven application model generator plugin can be used to automatically generate application model code whenever a Maven-based project is built.

Perform the following for each Maven-based project.


The application model code generator Mojo is dependent on the following JARs:

  • UFT Developer common and SDK JARs.

    Make sure that they are installed in your local or remote repository. For details, see Prerequisites for Maven-based projects.

  • AppModel code generator (helper) JAR.

    To deploy the JAR to your organization's repository, run the following command:

    mvn deploy:deploy-file





    To install the JAR to your local repository, run the following command:

    mvn install:install-file



    The path to the JARs and POMs is:

    • Windows: <UFT_Developer_installdir>\Tools\AppModelCodeGenerator\Java
    • Linux/Mac: <UFT_Developer_installdir>/Tools/appmodel-code-generator/Java


To configure the plugin

Note: Adjust the version number used below according to the UFT Developer version you are using.

For UFT Developer version Use
2021 2021.0.0
2021 R1 2021.1.0
2022 2022.0.0
2023 2023.0.0
23.4 2023.4.0
  1. Install the Mojo to your Maven repository. (Follow the instructions in Dependencies.):



  2. Enable the plugin.

    Open the project pom.xml file and uncomment the Application model generator plugin section.

  3. (Optional) Configure where the generated code file is placed.

    By default, the file is generated under the appmodels folder in the project.

    To change the location:

    1. Copy the following code into the configuration element in the Maven plugin section in the pom.xml:

      <!--The output directory of the generated application models.The Default is the appmodels folder under the project-->
      <!--<outputDir>set_path</outputDir> -->
      <!--If set to true, the  application models are generated next to the tsrx files. Mutually exclusive with the outputDir parameter -->
      <!--<inPlace>true</inPlace> -->
    2. Uncomment either the outputDir or the inPlace element, and edit as required.
  4. Save your changes to the file.

Back to top

See also: