Here is why you ought to be on LeanFT 14.01!

HP(Now Micro Focus) has stepped up their game with the updates to LeanFT all through 2017. The version change itself speaks volumes about the magnitude of the change from version 12.54 to 14.0. Maybe they were skeptical about the so-called “unlucky” number 13 🙂

Some of the worthy improvements in the 14.x upgrades are:-

  1. Cross Platform Support(14.0) – LeanFT now works on Linux and Mac also. This link has information about the specific features supported.
  2. Parallel Tests(14.0) – I have been waiting for this to be officially rolled out since the first launch of LeanFT. Though this was possible in earlier versions with some hacks, its good to see that LeanFT finally has this powerful and much needed feature. Get to know more at the documentation link.
  3. LeanFT for Selenium(14.0) – LeanFT expanded its umbrella by giving us this feature and saying that – “Go write your Selenium Tests the LeanFT way!”. By “LeanFT way,” I mean using the Object Identification Center(there is a dedicated one for selenium) to generate code. This actually makes test automation code generation much faster. Get started here.
  4. Test Recording(14.1) – Not a big fan of recording but people at HP have made a fortune out of selling the “Recording” feature in UFT so there must be a lot of audience for it. For all the recording fans out there, go play with LeanFT as you did with UFT! Read this article for getting started.
  5. Docker Support(14.1) – We can now use the LeanFT docker containers to setup our Test execution. This enables us to run our tests with close to zero effort in installation and is a boon for the CI/CD worshippers. Have a look at this link for more.
  6. StormRunner Integration(14.1) – LeanFT scripts can be used to run Performance tests through StormRunner. More information here.

I think the above points justify the fact that its called “UFT Pro”. You can go to the Micro Focus LeanFT website for more knowledge on LeanFT.

Happy Automating!

Harshit Kohli

How to create Functional Mobile Test in LeanFT (UFT Pro) in Visual Studio Part II

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 coding test objects manually. 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)

I have already covered creating Test Steps by adding Test Objects to Application Model in previous post. I will be covering creating Test Steps by coding Test Objects manually

  • Create new LeanFT MsTest Project
  • Add the following using statement
using HP.LFT.SDK.Mobile;
  • Click on Object Identification Center icon on the Visual Studio Toolbar

LFT_OIC

  • Using Object Identification Center, copy and paste the test objects description under Test Method section

MC_LFT_AM

  • Then, Code can be written using test objects description 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");
//declaring test objects
IApplication app = device.Describe<IApplication>(new ApplicationDescription
{
 Identifier = @"com.hpswdemo.advantageinc",
 IsPackaged = false
});

IEditField usernameField = app.Describe<IEditField>(new EditFieldDescription
{
ClassName = @"Input",
ResourceId = @"com.hpswdemo.advantageinc:id/loginUserNameEditText",
MobileCenterIndex = 0
});

IEditField passwordField = app.Describe<IEditField>(new EditFieldDescription
{
ClassName = @"Input",
ResourceId = @"com.hpswdemo.advantageinc:id/loginPasswordEditText",
MobileCenterIndex = 1
});

IButton loginButton = app.Describe<IButton>(new ButtonDescription
{
Text = @"LOGIN",
ClassName = @"Button",
ResourceId = @"com.hpswdemo.advantageinc:id/loginButton",
MobileCenterIndex = 0
});
//Installing and Launching Application
app.Install();
app.Launch();

//Enter Username and Password
usernameField.SetFocus();
usernameField.Tap();
usernameField.SetText("testuser");
passwordField.Tap();
passwordField.SetSecure("password");

//Tap Login Button
loginButton.Highlight();
loginButton.Tap();

//Unlock Device
device.Unlock();

 

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

How to connect LeanFT (UFT Pro) to HP Mobile Center

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 connect LeanFT (aka UFT Pro) to Mobile Center Server. You can go to post detailing the process of connected Real Android Devices to Mobile Center Connector Machine.

Following pre-requisites are required to setup LeanFT to execute Tests on Mobile Center:

  • HP Mobile Center Server machine should be powered on
  • Android Device should be connected to HP Mobile Center Connector Machine and should be detected
  • Compatible LeanFT version should be installed

Steps to configure UFT for Mobile:

  • Start/Restart  LeanFT Runtime Engine

leanft_runtime_engine

  • Right click on the icon and click on Settings

engine_rightclick

  • LeanFT Settings dialog box opens. Click on Show Settings link next to Mobile

leanft_settings.png

  • Under Connection Settings header, enter Server name, User name and Password for Mobile Center that we noted down in previous post
  • Also, check Use Proxy checkbox and enter relevant settings if applicable

leanft_connectionsettings.png

  • Click on Verify button. If settings are valid, then button will be changed to green Verified button. Also, a Success message will be displayed

leanft_connectionSuccess.png

  • Click on Save button to close the dialog box

Stay tuned for my next post detailing the process to create Functional Mobile Test in Lean FT

LeanFT Cucumber Framework – Lets talk Gherkin !

Imagine a room full of 50 people and you whisper a story in the ears of the first person and he narrates it to the second and so on till the 50th one. I’m pretty sure that if you narrated the first person “Star Wars”, then what you get from the 50th one would be something like “War of the Stars”. Somewhat analogous to our daily life in IT, a lot of the times what the client wants and what he ultimately gets are two different stories altogether 🙂

This is where the importance of communication can be realized. Behavior Driven Development(or BDD) aims to address issues like this by establishing a common vocabulary which is equally understandable by all stakeholders of a project. A language called Gherkin is used to define Features which contain scenarios which are nothing but a sequence of “Given,When,Then” statements that define a user flow in your application. Example:-

Cucumber, one of the most popular BDD frameworks can be used in conjunction with LeanFT to create a robust setup for Test Automation where the scenarios like the above can be converted into corresponding lines of code. I gave this a shot and the code is present on my GitHub account. Feel free to have a look at the code and make it your own. Suggestions/Comments welcome !

Happy Automating!

Harshit Kohli

LeanFT TestNG Framework – Kicking off your Automation!

So you’ve learnt the basics of LeanFT. What next ?

The obvious answer would be to start writing a Framework. Before you start fishing in the troubled waters, let me do a reality check. In my 7 years of experience, I have been writing frameworks for more than half the time. Trust me I could have done with using code that other people have written 🙂

That is exactly what I intend to do with this blog entry! Providing a starting point for people so that we can focus on what’s really important – AUTOMATION rather than framework creation. Some of the weapons in my arsenal(read components of the framework) include:-

  1. TestNG – The undisputed king when it comes to testing frameworks
  2. Maven – The defacto build automation tool for Java
  3. LeanFT – Our favourite test automation SDK 🙂
  4. Page Object Model is used for better organisation of the code.
  5. Log4J logs all the important events.

The code for the Framework can be found on this GitHub link. It can be used as a template to write your automation code. Feel free to fork it !

FYI: This framework should be easy to understand if you’ve worked with Selenium based frameworks before. In case of any difficulty in understanding, feel free to comment.

 

Happy Automating!

Harshit Kohli

 

How to Add LeanFT Dependency in Maven

Maven is an important component of a Test Automation Framework. If you want to add LeanFT dependencies in Maven, you need to perform the following steps:-

  1. Install Maven on your system. Mkyong explains it beautifully in his post here.
  2. Execute the following 2 commands on your command prompt to add the LeanFT Jars in your local maven repository:-
mvn install:install-file -Dfile="LeanFT Installation Directory\SDK\Java\com.hp.lft.sdk-standalone.jar" -DgroupId="com.hp.lft" -DartifactId="sdk" -Dversion=14.0.0 -Dpackaging=JAR -DgeneratePom=true

mvn install:install-file -Dfile="LeanFT Installation Directory\SDK\Java\com.hp.lft.report.jar" -DgroupId="com.hp.lft" -DartifactId="report" -Dversion=14.0.0 -Dpackaging=JAR -DgeneratePom=true

mvn install:install-file -Dfile="LeanFT Installation Directory\SDK\Java\com.hp.lft.unittesting.jar" -DgroupId="com.hp.lft" -DartifactId="unittesting" -Dversion=14.0.0 -Dpackaging=JAR -DgeneratePom=true

mvn install:install-file -Dfile="LeanFT Installation Directory\SDK\Java\com.hp.lft.verifications.jar" -DgroupId="com.hp.lft" -DartifactId="verifications" -Dversion=14.0.0 -Dpackaging=JAR -DgeneratePom=true

mvn install:install-file -Dfile="LeanFT Installation Directory\SDK\Java\com.hp.lft.sdk-javadoc.jar" -DgroupId="com.hp.lft" -DartifactId="sdk" -Dversion=14.0.0 -Dclassifier=Javadoc -Dpackaging=JAR -DgeneratePom=true

mvn install:install-file -Dfile="LeanFT Installation Directory\SDK\Java\com.hp.lft.common.jar" -DgroupId="com.hp.lft" -DartifactId="common" -Dversion=14.0.0 -Dpackaging=JAR -DgeneratePom=true

mvn install:install-file -Dfile="LeanFT Installation Directory\SDK\Java\com.hp.lft.reportbuilder-standalone.jar" -DgroupId="com.hp.lft" -DartifactId="reportbuilder" -Dversion=14.0.0 -Dpackaging=JAR -DgeneratePom=true

3. Add the Following dependencies in your pom.XML:-


<dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>sdk</artifactId>
    <version>14.0.0</version>
</dependency>

<dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>sdk</artifactId>
    <version>14.0.0</version>
    <classifier>javadoc</classifier>
</dependency>

<dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>report</artifactId>
    <version>14.0.0</version>
</dependency>

<dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>unittesting</artifactId>
    <version>14.0.0</version>
</dependency>

<dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>verifications</artifactId>
    <version>14.0.0</version>
</dependency>

<dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>reportbuilder</artifactId>
    <version>14.0.0</version>
</dependency>

<dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>common</artifactId>
    <version>14.0.0</version>
</dependency>

Please note that the version specified in the Command line arguments and the pom.XML would change depending on the version of LeanFT installed on your machine.

Happy Automating !

Harshit Kohli

LeanFT Service Pack 3 – Whats New ?

LeanFT just got more AWESOME ! HP recently launched Service Pack 3 and here are some of the cool features:

  • Parallel execution on the same machine: Speed up your testing by running in parallel multiple tests on the same host on your Web applications. Reduce your Total Cost of Ownership because with one LeanFT license you can execute up to four tests at a time.
  • IntelliJ IDEA is now supported with LeanFT for creating LeanFT’s test projects and enjoying all the advantages of our solution like application models and the identification center.

                                                                                 432.JPG

  • TestNG, NUnit3, Maven-based Java projects are now supported, expanding our support of unit-test frameworks
  • JavaScript SDK main enhancements: OCR, More tech: Insight, SAPUI5, Access to the NativeObject, Checkpoints
  • Creating Business Components for BPT
  • Mobile testing enhancements: Using LeanFT and Mobile Center 2.00, you can now:
    1. Support non-packaged apps. This means you no longer need to package apps and to upload them to Mobile Center.
    2. Dynamically select and lock a device for your test by specifying the device’s operating system type and version.
    3. Access mobile device logs from the LeanFT run report.
  • Business Process Testing (BPT) is now supported as you can transform any LeanFT test to become a LeanFT business component, bringing together the best of both worlds—rapid test automation leveraging developer environments and the ease of creation and maintenance that comes from adopting a component test framework .

For downloading the Latest version, you need an HP License. In case you have one, you can download from this link.

If you want to Learn LeanFT, you can start from here.

 

Happy Automating!

Harshit Kohli

LeanFT Java Tutorial Part 9 – Using LeanFT and Selenium Together !

I don’t want to debate which tool is better, of course both tools have their advantages and disadvantages. So lets use all the advantages together in a mega script which uses both technologies. For doing this, you have to:-

  1. Create a LeanFT JUnit Project in Eclipse.
  2. Download Selenium Libraries from here and extract to a desired location.
  3. In your Eclipse project, right click the Project name and goto Build Path -> Configure Build Path.
  4. Click on Add External Jars option and add the selenium-java-{version}.jar from the extracted location.
  5. Also add all the jars in the libs folder.
  6. If you are working with Chrome, you need to additionally download the chromedriver.exe from here.
  7. Now the setup is done, you can get your hands dirty with the following code:-

package l2a;
import static org.junit.Assert.*;
import java.io.File;
import org.junit.*;
import com.hp.lft.sdk.*;
import com.hp.lft.sdk.web.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.*;
import unittesting.*;

public class LeanFtTest extends UnitTestClassBase {

 public LeanFtTest() {
 //Change this constructor to private if you supply your own public constructor
 }

 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
 instance = new LeanFtTest();
 globalSetup(LeanFtTest.class);
 }

 @AfterClass
 public static void tearDownAfterClass() throws Exception {
 globalTearDown();
 }

 @Before
 public void setUp() throws Exception {
 }

 @After
 public void tearDown() throws Exception {
 }

 @Test
 public void leanFTSelenium()
 {
 try
 {
 //Setting the Path for Chrome Driver
 System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");

 //Adding the Chrome Extension for LeanFT
 ChromeOptions CO = new ChromeOptions();
 CO.addExtensions(new File("C:\\Program Files (x86)\\HP\\LeanFT\\Installations\\Chrome\\Agent.crx"));

 //Launching Chrome with Selenium
 WebDriver driver = new ChromeDriver(CO);

 //Navigating to Google
 driver.navigate().to("https://www.google.com");

 //Attaching to the Browser with LeanFT
 Browser browser = BrowserFactory.attach(new BrowserDescription.Builder()
 .type(BrowserType.CHROME).build());

 //Navigating to Learn2Automate on the same browser instance
 browser.navigate("https://learn2automate.wordpress.com");

 }
 catch(Exception ex)
 {
 ex.printStackTrace();
 Assert.fail("Unexpected Error occurred - " + ex.getMessage());
 }
 }

 

After writing the above code, your “browser” and “chromeDriver” objects are pointing to the same browser instance. You can now use both objects interchangeably in your script, this essentially means you can write either Selenium or LeanFT code for performing an action on your browser. Talk about Flexibility !

For more information on using Selenium in Java, you can refer many blogs that write about it.

In case you are interested in knowing about a TestNG based LeanFT framework, click here.

Happy Automating!
Harshit Kohli

LeanFT Java Tutorial Part 8 – Running Tests Remotely

The Eclipse IDE is heavy and may take a toll on the system memory-wise. So its advisable to have two separate kinds of machines – one for development of scripts and one for execution. The machines that we use for execution need not have the full IDE and we can just have the LeanFT Runtime engine running on them.

So when you are installing LeanFT, you can select the following option when you just want to use the machine for execution :-

LeanFTInstallation

In your Eclipse project on the development machine, you need to open the leanft.properties file, uncomment the server address and update the execution machine details as follows:-


# The LeanFT runtime engine URL and port. Default: ws://localhost:5095
serverAddress=ws://execution_machine_name:5095

In your execution machine, open the following file:-

C:\Program Files (x86)\HP\LeanFT\bin\LFTRuntime.exe.config

Update the the connection key in the XML to have mode as “AcceptNonSecuredRemoteConnections” rather than the default value which is “AcceptLocalConnectionOnly” :-

<connection port="5095" mode="AcceptNonSecuredRemoteConnections">

Please make sure that the port number mentioned here is the same as one mentioned in the leanft.properties file in the dev machine. Also, make sure you restart the runtime engine after making this change.

Now, if you start the code in your dev machine, it should run on the execution machine provided they are on the same domain.

LeanFT Java Tutorial Part 9 – Using Selenium and LeanFT Together !

Happy Automating!
Harshit Kohli