LeanFT Tutorial - Create Tests in LeanFT

In this post of LeanFT/UFT Pro tutorial series, we will go through steps to create tests in LeanFT and learn about IDE project templates and prerequisites. As mentioned in earlier posts, we are using IntelliJ and Java for this tutorial. Let us know your experiences and issues (if any) with any other tools, in the comments section.

Create Tests in LeanFT

LeanFT works with different IDEs of your choice such as Visual Studio, IntelliJ, Eclipse. LeanFT provides plugins for these IDEs to get along with different options and settings. Refer our earlier post on Getting Ready with LeanFT for more details on setting up LeanFT for different IDEs. LeanFT plugin comes with built-in project templates to provide initial structure for your project and basic initial references.

Project Template for IntelliJ

You can create a Selenium based project or a Maven based project. If you want to create Selenium based project, LeanFt provides LeanFT for Selenium, a solutions which extends the Selenium APIand enables to create more robust and easily maintainable Selenium tests.

To start with a Maven based project, you should install LeanFT JARs to the Maven Repository local or to your organization’s repository. You can do this easily by running the commands below


mvn install:install-file



Organization’s Repo

mvn deploy:deploy-file





Now we need to create the test from IDE, since we are using IntelliJ, goto menu Option “File> New Project”. Follow the wizard

Select Testing Framework and SDK, check create a maven project option if you want to create maven based project.

Select Selenium if you want to use Selenium based project. You will need to select the JAR file from LeanFT installation folder.

Follow the rest of wizard and your test will look like below

For a JUNIT test it looks something like below

As you can see, a LeanFT class has been created, which we will use to script and automated our scenarios.

Automate a Web Application

Once you have the basic or initial project template you can start writing your test. Alternatively you can also have your custom framework and project template. You can also use Test Recorder to accelerate your test creation.

Since you have the base project created, as described in previous section. Lets now write our scripts for the test. The most important method in the LeanFTTest Class created above is the “test” method. Since we have created our project as LeanFT SDK, LeanFT SDK libraries will automatically gets included into the project. In case of Selenium, all the relevant libraries gets included.

See also  LeanFT Tutorial #2: Browser Extensions and Settings

Since we are going to automate a web application, we will need to import relevant package to work with web applications. Lets import the leanFT web Package. Add the statement below to the import section at top.

import com.hp.lft.sdk.web.*;

Now will write the code to launch the browser in our test method. You can change the method name to some meaningful name of your choice based on your test.

The first thing you need to do while automating a web application is to decide which browser you are going to use and then launch. It will depend on various factors like application compatibility, feature/behavior to test etc.

Note that Browser must be configured appropriately to work with LeanFT. Refer our post on Browser Extensions and Settings

In this example we are going to use Chrome browser and will navigate to new tours website. We will use BrowserFactory Method to do this.

public void MyFirstTest() throws GeneralLeanFtException {
Browser browser = BrowserFactory.launch(BrowserType.CHROME);



Extend Test to Include More Tests and Actions

Now we can extend our test to include more tests and operations to AUT. We have already seen Object Identification Center and Application model to include test objects in test project. Using these we can now perform different operations as required.

When you defined the browser here, it becomes the top level parent object and now you go down to the hierarchy of objects and create test object as child of the relevant parent object. Use OIC to determine different set of properties to describe your object.

Use Describe method to create the child object.

MyVar = parentObject.describe(TestObjType.class, new TestObjTypeDescription.Builder()


For example

browser.describe(Link.class, new LinkDescription.Builder()

.tagName("A").innerText("Business Travel @ About.com").build());


Run your LeanFT Test

Simply right click on your test method and select Run Test Method option

run the test using Maven:

To run your tests locally, you need to compile your project and then use either your testing framework’s runner like NUnit or JUnit, to run your compiled .dll or .jar, or any other relevant runner.

Step 1: In your project’s pom.xml file, Create a property for the test source directory:




Under the build tag, add:


Create a LeanFT profile:









Step 2: Run mvn test –P leanft-test.

Run Results

When you run LeanFT tests created from a LeanFT project template, an HTML report is automatically generated. The report includes summary information about the run as well as detailed information about the captured steps.

To View the result, goto menu Option “LenFT> View Last Run Results”

See also  LeanFT Tutorial #3: Object Identification Center (OIC)



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.