This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LeanFT - Using two different Application Models in a Project

Hello

We are testing our Mobile App(Hybrid Application) with LeanFT and we have a bit of a problem.

Our IOS and Android App Object Recoqnition is quite a bit different. So we have to use two different AppModels even tough they have the same structur and same Objects. Just the object properties in the Identification are different.

The Problem now is that we have to write double the code for the same test, even tough everything is the same but the AppModel.

 

For example:

Device device = MobileLab.lockDeviceById("ID");
appModelBase = getAppModel();
if (master.getDevice().getOs().equals("IOS")) {
ApplicationModelIOS ios = (ApplicationModelIOS) appModelBase;
ios.MobileApp().launch();
} else{
ApplicationModelAndroid android = (ApplicationModelAndroid) appModelBase;
android.MobileApp().launch();
}

The getAppModel  method:

public static AppModelBase getAppModel() throws GeneralLeanFtException {
if (master.getDevice().getOs().equals("IOS")) {
return new ApplicationModelIOS(device);
} else if (master.getDevice().getOs().equals("Android")) {
return new ApplicationModelAndroid(device);
} else {
throw new GeneralLeanFtException("Could not create Application Model. Make sure to set the the correct Device in the Excel.");
}
}

 

Is there anyway to reduce the lines of code? Should we create our own AppModel?

 

Thanks

Davor

  • 0

    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.
    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.

    Step 4: Now provide the project name as well as the package name like com.test and click on the Next button.
    Step 5: Java Setting window be displayed, select the Libraries tab, and select the classpath option and click on the “Add Library” button.
    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.

    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.

    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.