In this post, we are going to focus on Application Model in LeanFT. Refer to our earlier posts on LeanFT
Getting Ready with LeanFT
Browser Extensions and Settings
Object Identification Center
We are using IntelliJ IDEA for all the demonstrations for this tutorial series. If you are using any other IDE and facing any issues, let us know via comments, we will try our best to help.
In this Post
What is the Application Model?
Application Model is like Object Repository in UFT. It contains the test object’s hierarchy, description and properties. The applications model enables you to maintain your test objects at a single location for use across the entire suite.
How to Create an Application Model?
Application Model can be created as a dedicated Application Model project or as a part of an existing Project.
Create a New Application Model
Step 1: Open New Project Wizard from Menu Option – File> New Project
Select LeanFT Option on the left and Application Model Project on the right.
Click Next
Step 2: Select “Create as Maven Project” if you are creating an application model as Maven Project else Ignore and click “Next”
Step 3: Provide Project name, Location details and click “Finish”
Create Application Model in an existing project
In the project explorer pane, right-click the src folder
select New > LeanFT Application Model item, and provide a name for the item.
The item (.tsrx) is added under the src folder and a corresponding .java file is generated under the appmodels folder.
Application Model File Extension
When you create a new LeanFT application model, two files are created: A .tsrx file that can display the Application Model editor as a rich user interface or as an XML file, and a tsrx.cs 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.
Adding Test Objects Manually
Step 1: Open the application model and Click on the “create new test object” button.
Step 2: New object pane will be displayed
Step 3: Provide the object name, technology, type and description for the object.
Step 4: Once you select the technology and the type of the object, you will see the list of properties populated for the object.
select the properties you want to use and provide the values for the selected properties.Enable regular expressions, by clicking on the star next to the value textbox.
Step 5: Click on the Save button on top, Test object will get added to the Application model
If you want to see only the used properties, click on the “Used” button else select “All” to see all properties
That’s it, you have successfully added your test object to the application model. Let’s see, if you have done it correctly and used appropriate properties for objects to be identified. Just like in UFT and TestComplete, LeanFT also has a “highlight object” feature. Select added test object and click on the highlight button.
If LeanFT is able to identify the object, you will get a successful message as below
Add Test Objects using Object Identification Centre
Refer to our earlier post on Object Identification Center (OIC)
At the bottom of the OIC, click the Add object pop-up button and select Add or Locate.
Add: In simple mode, All starred objects that do not yet exist in the listed application model are added. While in Edit mode, The object that is in focus is added, as well as any checked parent objects that do not yet exist in the application model.
Locate: If a test object in the listed application model matches the description the OIC is using, the application model opens and that object is selected in the model. If you checked an object and one or more parents, the OIC first looks for the parent objects, and then tries to locate the selected test object only within the specified parent objects.
Using Application Model in Test
In your LeanFT test, add an import line for your application model. Instantiate the application model class and start using objects.
Sample :
import com.hp.lft.DummyItem;
@Test
public void test() throws GeneralLeanFtException {
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
DummyItem.appmodel = new DummyItem(browser);
appModel.SignOnMercuryToursPage().HomeTable().Submit()
}
Convert UFT Object Repository to LeanFT Application Models
LeanFT comes with a small utility program that helps to convert existing UFT repositories to application models. This is named – OR2APPMODELCONVERTER and can be found in LeanFT installation folder
<LeanFT installation folder>\bin
If LeanFT is installed with UFT, you can find it at UFT installation folder
<UFT installation folder>\bin
The usage syntax is as follows:
OR2AppModelConverter ObjectRepositoryFile ApplicationModelFile LogFile LogLevel
ObjectRepositoryFile | Provide the full path to the repository. It can be:
Note: If the repository you provide includes test objects from UFTadd-ins that do not have a parallel in LeanFT, those objects will be ignored during the conversion. |
ApplicationModelFile | The full path of the application model (*.tsrx) file you want to create. |
LogFile | Optional. The full path of a log file containing details of the conversion.
Although this option is optional, it is recommended. If the utility is unable to convert a test object or a specific identification property inside a test object description, that information is indicated in the log (if you use the LogFileoption). You can use this information to fix such issues manually in the LeanFT Application Model editor. |
LogLevel | Optional.The minimal severity level to include in the report. Possible values: Info | Warning | Error.
For example, if you specify Warning, then Warnings and Errors will be written to the report, but general information data will be excluded. |
[…] add objects in application model, you must launch OIC from Application Model. At the bottom of the OIC, click the Add object pop-up button and […]
Great tutorials. How would you set up an external application model in Jenkins?
Thanks Bryan. Would you like to elaborate the scenario a bit? I am sorry, I could not understand the external application model setup in Jenkins.
Hi Saket,
I am trying to write a script in Java language to test the file upload functionality in LeanFT 14.5. I captured activity by OIC/Application Model, however, it is not running.
Please help me.
Thanks,
Manish Kumar
Hi Saket,
Please find code-snippet:
@Test
public void testUploadFile() throws GeneralLeanFtException {
//Launch Chrome
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
browser.navigate(“https://uploadfiles.io/”);
//This is NOT getting invoked while running
browser.describe(WebElement.class, new WebElementDescription.Builder()
.innerText(“Drop file here or click to upload. (5GB max) “).tagName(“FORM”).build()).click();
}
Thanks,
Samir
Hi Saket,
Please find code-snippet:
@Test
public void testUploadFile() throws GeneralLeanFtException {
//Launch Chrome
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
browser.navigate(“https://uploadfiles.io/”);
//This is NOT getting invoked while running
browser.describe(WebElement.class, new WebElementDescription.Builder()
.innerText(“Drop file here or click to upload. (5GB max) “).tagName(“FORM”).build()).click();
}
Thanks,
Manish Kumar