Create Application Model Project in LeanFT & Write First Test

A LeanFT (now known as UFT Developer) application model project is made up 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. In this article, you will see how to create an Application Model Project in LeanFT.If you would have worked with UFT, you will feel that an application model in LeanFT works in the same fashion as using a shared object repository in UFT.

Adding a Synchronization point is a must thing to make your test scripts robust. Please refer to my post How to Use WaitUntil method in LeanFT to add dynamic wait in automation scripts rather than using hard wait.

Note: The screenshots in this article are of LeanFT. However, the steps of creating a project in LeanFT and UFT Developer are the same. Please select the relevant options while creating the project.

When a new LeanFT application model project is created, two files are created:

  • .tsrx . An XML representation of the application model and its objects. It is similar to a shared object repository in UFT. This .tsrx file is empty when the application model project is created and it is automatically when you add new objects in it.
  • .tsrx.cs( in visual studio) or .java. A file containing the code for the application model class.
For each application model (.tsrx file), LeanFT creates a .java file and each application model is compiled into a class that can be instantiated in the test script, enabling us to access the complete test object model of our application. Whenever an object is added to the application model (.tsrx file), the corresponding class is also updated automatically.

Create Application Model Project in LeanFT | UFT Developer

Step 1: Go to File>New>Project

Step 2:  If you are working on an older version that is LeanFT, select the LeanFT > LeanFT Application Model Project and click on the Next button. On the current version, you can select options starting with UFT Developer.
 
Step 3: A window be shown that gives us the option to create a Maven project.If you do not want to create a Maven project click on the Next button without selecting the checkbox.
 
maven project option uft developer
 
Step 4: Now provide the project name as well as the package name like com.test and click on the Next button.
 
Application Model Project in LeanFT
 
Step 5: Java Setting window be displayed, select the Libraries tab, and select the classpath option and click on the “Add Library” button.
 
Java Settings
 

Step 6: 
Select the TestNG library and click on the Next button.If TestNG is not installed in the eclipse. Refer to my post Install TestNG in Eclipse IDE.
 
eanFT-Application-Model-Project-3
 
Step 7: In the next window you will get a message “This will set the default TestNG Library to this project”. Click on the Finish button.
 
Step 8: TestNG Library will be added to the Libraries Tab.
 
 
Java Settings testng library

Step 9:
Click on the Finish button. If you get another dialog box named “New module-info.java“, click on the “Don’t Create” button. The application model project will be created in the Package Explorer and an empty ApplicationModel.tsrx file would be displayed under com.test package. This is the object repository of the LeanFT project. You will see two packages with the same name com.test, one under the src directory, and the other one in appmodels directory. You can write your test scripts in your src directory.
 
Application-Model-LeanFT
 
The next step would be to add the test objects to the application model.
 

Add Test Object To Application Model Or Create LeanFT Object Repository

Step 1: To add test objects in the application model click on the hat icon in the application object model.
 
Add-objects-to-Application-Model-LeanFT

Step 2: 
Object Identification Center (OIC) utility for the application model will open.
 
OIC-Application-Model-LeanFT

Step 3: 
Activate your test application and click on the hat icon on OIC to start spying test objects. Click on the required objects that you want to add them to the application model. Once you are done press the ESC key on the keyboard or stop the spying objects. You will see the added objects in the OIC.
 
 OIC-Application-Model-LeanFT-1

Step 4: 
Click on the “Add Objects to ApplicationModel” button. All selected objects would be added to the application model.
 
OIC-Application-Model-LeanFT-2
 
Step 5: Now if you switch to Eclipse IDE and see the Application Model, the added object will be displayed here. I have added objects to log in to HP Sample Flight ApplicationSave the Application Model.
 
Test Object Application Model LeanFT

Create First Test For Application Model Project

If you open the ApplicationModel.java file inside the appmodels directory you will see that the application model has been compiled into a class. We will create an instance of this class in our test script. Do not modify this class file.
 
ApplicationModel-java-File-1
 

Steps to create a Test in LeanFT Application Model

Step 1: Select the package under the src directory and create a new class inside it.
 
eanFT-Application-Model-Class

Step 2: 
Enter a valid class name (LeanFTAppModelDemo) and click on the Finish button.
 
Step 3: Now copy the following code in the aforementioned class file.

Step 4: Now run this script as TestNG Test. Do a right-click anywhere in the Test and select “Run As>TestNG Test”

Add a new Application Model Item in a LeanFT Application Model Project

Follow the following steps to add a new application model item in an existing LeanFT Application Model Item Project.

Step 1: Right-click on the package (com.test) and select New > Other.In the New dialog, select the LeanFT Application Model Item (or UFT Developer Application Model Project in the latest version) and press the Next button.

 LeanFT-Application-Object-Model-Item-Project

Step 2: Give the new application model item name and click on the Finish button.

LeanFT-Application-Object-Model-Item-Project-2

Step 3: The new application model item will be added to the Eclipse project. Now you can add the test objects in it.

Adding-LeanFT-Application-Object-Model-Item

You can also refer to my post on Create a UFT Developer | LeanFT Testing Project & Write Your First Test in Java to create an automation script using descriptive programming.

Recommending Posts

Leave a Reply