How to use LeanFT with C# Visual Studio Applitools

How to use LeanFT with C# Visual Studio Applitools

Visual Validation Tools

Last week, I was a guest speaker for an HP/Applitools webinar about Advanced Cross-Browser Testing Techniques. I also demonstrated how to use Applitools with LeanFT, HP’s new automation tool. I’d like to share some of my notes from a few of the things I shared on the call.

What is LeanFT?

First of all, you may be asking, “What is LeanFT?” LeanFT is HP’s new test tool, which they have developed to handle the modern automation demands of things like continuous testing and dev-ops.

LeanFT for modern test automation

What’s really cool is that LeanFT fits into the developer’s ecosystem, so you can use the same tools your developers use to create automation scripts. LeanFT supports technologies like Visual Studio and Eclipse, using either C# or Java, and supports unit testing frameworks like jUnit, NUnit, MSTest, and versioning control systems like GIT.

LeanFT supports many technologies

Bonus — LeanFT allows you to be able to access HP’s Windows-based technologies that Selenium does not allow, since Selenium is for browser testing only. If you work for a large organization, undoubtedly your end-to-end tests often require some sort of interaction with a non-browser application. With LeanFT, you can script everything — browser and non-browser interactions — all in one framework!

Using C# and LeanFT

Let’s take a look at how to create a LeanFT test in Visual Studio using C#.

For this demonstration I’m navigating to the web page, then clicking on the resources link.

Create a simple LeanFT script

  • First, select your test type. When you start up Visual Studio on your LeanFT machine you’ll notice three new templates under the C# section. You can create LeanFT script using either MSTest or NUnit. (For this example I’ll be using MSTest.) When you select one of the templates, your new project will include all the MSTest or NUnit framework annotations you’ll need to get started.
  • Next, because we want to test a web application we’ll first need to import the HP.LFT.SDK.Web
  • Under the TestMethod section, declare a Chrome browser instance:

IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);

Once we have a browser variable of type Browser we can access all the methods available for the browser object. Many of the methods that you’re already familiar with for the Browser object in UFT/QTP are also available in LeanFT. Now let’s navigate to our website:


  • Next, click on the Resources link. We’re going to create a test object that includes unique property values to help ID the object you want LeanFT to work with in your app. There are a few ways to do this, but for now we will use the LeanFT Object Recognition Center (ORC — think QTP spy) to help create the object description we need.
  • Click on the LeanFT ORC icon in Visual Studio, then click on the Star spying option.

  • Open up a browser and navigate to LeanFT, then point to the Resources link.
  • The LeanFT ORC will list all the properties it found for the object, and will place a Start icon next to all the properties it recommends you use to uniquely identify that object. For the Resources link it recommends InnerText, TagName and Index,
    so go ahead and click them.

  • Ensure that it finds the object by clicking on the Highlight option. It should locate the Resources link.

  • Next, click on the Generate code to clipboard option.
  • Close the ORC and the browser.

  • In your test under the browser navigate statement, paste the object definitions that the OR created for us, then add a variable named resourceLink in front of it:
var resourceLink = browser.Describe(new LinkDescription
TagName = @"A",
InnerText = @"Resources",
Index = 0
  • Next let’s click on the Resources link — but before we do, let’s make sure that the link exists. To do this we’ll use the good old QTP/UFT Exist method.
Boolean doesExits = resourceLink.Exists(5);


  • If the link exists we will click on it. If it doesn’t, we’ll report a failure to the new LeanFT HTML report option.
if(doesExits ==true)
Reporter.ReportEvent("Link Exist Check,"Verify that link exists value is=" + doesExits, HP.LFT.Report.Status.Passed);
Reporter.ReportEvent("Link Exist Check","Verify that link exists value is= + doesExits, HP.LFT.Report.Status.Failed);
  • Once again — if you’ve used QTP or UFT before, this syntax should look very familiar to you.
  • Lastly we will close the browser:


  • Run the test in Visual Studio by clicking on the Test>Run>All Tests menu option.

Easy cross browser testing using LeanFT

Cool! Now, to run against another browser all you have to do is change the browser type and rerun. No other code needs to be changed. For instance, to run against Firefox, just change the BrowserType to Firefox.

Applitools Eyes

In the webinar, I demonstrated how easy it is to add visual validation functionality to an existing LeanFT test. (I’ll go over this step by step in another post.) But for now, be sure to check out the entire webinar to learn about all the benefits of visual validation testing and why it’s so important.

More on LeanFT

For a more detailed demonstration of using LeanFT, be sure to sign up for the HP VIVIT LeanFT webinar Shift Left with Lean Functional Testing that I will be a guest speaker on next Friday.

Sach - July 31, 2015

Thanks for the headsup on LeanFT. I tried to create a basic test using Leanft in Visual Studio 2012. But the ORC is disabled in the Visual Studio Menu. How do i enable it? Thanks in advance.

    Joe Colantonio - August 4, 2015

    Thanks Sach I’ve been trying to repro but can’t. What version of Visual Studio are you using? Does everything else work for you?

Sri Harsha - September 29, 2015

This is an excellent article on getting started with LeanFT. I am trying to spy a link on a browser and the OIC selects the whole browser. Why is it happening? Does this have anything to do with any add-ins that are not loaded or b/c of unsupported browser versions? Please do let us know. Thank You for sharing your knowledge with the rest of us.

Sri Harsha - September 29, 2015

Never mind…didn’t enable the extensions after the upgrade.

VGM - January 7, 2016

I have created Junit LeanFT project in Eclipse , able to spy but the script Browser browser = BrowserFactory.launch gives com.hp.lft.generalservererror. How do I go about this?

    Joe Colantonio - January 8, 2016

    Are you passing it the BrowserType parameter? Like this:
    Browser browser = BrowserFactory.launch(BrowserType.FIREFOX);

VGM - January 13, 2016

Yes Joe

Browser browser = BrowserFactory.launch(BrowserType.CHROME);

but script fails at first line Browser browser = BrowserFactory.launch(BrowserType.CHROME); and gives general error


com.hp.lft.sdk.GeneralServerErrorException: General Error occurredPicked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:”C:\Program Files\HP\LeanFT\bin\java_shared\classes”;”C:\Program Files\HP\LeanFT\bin\java_shared\classes\jasmine.jar”

Thanks in Advance

Debojyoti Choudhury - February 25, 2016

Does LeanFT support terminal Emulators?

    Joe Colantonio - March 10, 2016

    As of now no. I don’t know HP’s roadmap for LeanFT but I don’t see terminal emulator support being a hi priority for LeanFT.

Jayasekhar Varma - August 8, 2017

Hi Joe, Can you help us to install MSTest template in Visual studio

Arun - November 27, 2018

How to perform keyboard operations using C# and Lean FT in Visual studio ?

Click here to add a comment

Leave a comment: