LeanFT

How to create Functional Mobile Test in LeanFT (UFT Pro) in Intellij (Java) Part I

This post is a part of our Mobile Testing series using HP Mobile Center. Please go to our previous articles in this series to learn about HP Mobile Center.

In this post, I will discuss how to create Functional Mobile Test in LeanFT (UFT Pro) in Intellij. You can go to post detailing the process of connecting LeanFT (UFT Pro) to Mobile Center.

First of all, we have to connect to Mobile Center server to open application in device connected to Mobile Center to create Test Objects

Open Application Under Test (AUT) in Mobile Center 

  • To do that, click on LeanFT > HPE Mobile Center Icon in Intellij Toolbar

MC_Icon_Intellij

  • If LeanFT is connected successfully to Mobile Center (as detailed in previous post), then the following box will appear:

MC_LFT.png

  • Then click on dotted button against Application and Device fields to choose Application and Device respectively
  • Select either Install Application OR Restart Application checkbox if selected application is not installed on the selected device and needs to be installed OR restarted

MC_LFT

  • Click on Launch button after selecting Device and Application. A window with selected device and application (AUT) opens for user to start capturing properties of the objects in the device

MC_App

Create Test Steps:

Now, we are ready to add/create objects of the Mobile Application in our LeanFT Test. We can do it in 2 ways:

  • Either adding test objects to Application Model
  • Capture Test Object properties using Object Identification Center (spy)

We will be covering creating Test Steps by adding Test Objects to Application Model in this post.

  • Create new LeanFT Application Model Project
  • Create it as a Maven project
  • Add LeanFT dependencies as described here
  • Add Test Objects to it

MC_LFT_AM.png

  • Once all the test objects are added, then save the project and execute mvn install command
  • A jar file will be created in the local maven repository path
  • Note down the group, artifact and version of this project from pom.XML file. It should look something like below:
<groupId>mobile</groupId>
<artifactId>mAppModel</artifactId>
<version>1.0-SNAPSHOT</version>

 

  • Close the existing project after saving it and create new LeanFT JUnit Project
  • Create it as Maven project
  • Add LeanFT dependencies as described here
  • In pom.xml , add the following dependency
<dependency>
      <groupId>mobile</groupId>
      <artifactId>mAppModel</artifactId>
      <version>1.0-SNAPSHOT</version>
</dependency>

 

  • Then, in test method under @test annotation, code can be written using test objects added in the Application Object Model using the below hierarchy depending on the application type:

                       Native Application:
                       Device > Application > Test object

                       Mobile Web Application:
                       Device > Application > WebView > Page > Test object

  • First, the device should be locked using any of the methods (such as lockDeviceByName,lockDeviceById etc) of MobileLab class so that no other can use the device while test is getting executed
  • Device should be unlocked using unlock method of created device object so that it is free to use

//locking device
Device device = MobileLab.lockDeviceByName("Vijay's Emulator");

//instantiating Application Model Class
ApplicationModel aModel = new ApplicationModel(device);

//Installing and Launching Application 
aModel.AdvantageApplication().install();
aModel.AdvantageApplication().launch();

//Enter Username and Passsword 
appModel.AdvantageApplication.UsernameFieldEditField.setFocus(); 
appModel.AdvantageApplication.UsernameFieldEditField.tap(); 
appModel.AdvantageApplication.UsernameFieldEditField.setText("testuser"); 
appModel.AdvantageApplication.PasswordFieldEditField.tap(); 
appModel.AdvantageApplication.PasswordFieldEditField.setText("Password"); 

//Tap on Login button 
appModel.AdvantageApplication.LoginButton.tap(); 

//Unlocking device 
device.Unlock();

Stay tuned for my next post detailing the process to code Test Objects manually

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s