LeanFT

How to create Functional Mobile Test in LeanFT (UFT Pro) in Visual Studio 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 Visual Studio. 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 Red Mobile Center Icon in Visual Studio Toolbar

MCIcon_LFT.png

  • 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
  • Add Test Objects to it

MC_LFT_AM.png

  • Once all the test objects are added, then save the project and click on Build > Build Solution 
  • A DLL file will be created in the following path. This file will be used further
                     <Lean FT Application Model Project Path>\ bin\Debug

LFT_BuildSol

  • Close the existing project after saving it and create new LeanFT MsTest Project
  • In Solution Explorer section , right click on References and add the dll file created in the previous step

LFT_AddReference

  • Add the following using statements
using HP.LFT.SDK.Mobile;
using MobileApplicationModel;

where MobileApplicationModel = LeanFT Application Model Project Name

  • Then, under Test Method section, 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
 var device = MobileLab.LockDeviceByName("Vijay's Emulator");

//instantiating Application Model Class
 var appModel = new mAppModelClass(device);

//Installing and Launching Application
 appModel.AdvantageApplication.Install();
 appModel.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

1 reply »

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