Selenium and LeanFT: Easily integrating LeanFT into your Selenium-based projects

by in Application Delivery Management


(This post was written by Anton Kaminsky from the LeanFT R&D Team)


LeanFT Functional Testing (LeanFT), is a new functional test automation solution, targeted to advanced automation engineers and dev-testers in agile teams. LeanFT provides comprehensive SDKs for both .NET and Java, as well as plugins for these IDEs, which include several powerful tools like the Object Identification Center and Application Models. LeanFT supports automating applications for a wide range of technologies including Web, Mobile, .NET and Java applications.


Using Selenium to automate your applications but would like to start using LeanFT? don’t worry!

In this blog we’ll see how you can use Selenium and LeanFT within the same tests suite (and even within the same test), and by that, migrate your Selenium project to LeanFT s gradually.


The blog covers the following scenarios:

  • LeanFT-Selenium Side-by-Side – Create a project having both Selenium and LeanFT tests
  • LeanFT-Selenium in One - Create a project that combines LeanFT and Selenium steps in a single test


If you already have tests in Selenium, you can continue using them, add new tests in LeanFT, and even combine LeanFT capabilities in your existing Selenium tests. And then over time, you can re-write your Selenium tests to LeanFT tests to improve your continuous testing process.


For the sake of this example, we will create a test using Java in the Eclipse IDE. Similar steps can be done using C# and the Visual Studio IDE.

 Before You Begin

Install LeanFT with the Eclipse plug-in. 
Don’t forget to specify the location of your Eclipse.

 LeanFT-Selenium Side-by-Side

1. Create a Selenium test. 

In the following Selenium test, we launch Chrome, navigate to Wikipedia, search for ‘Star Wars’ and then verify the release date of the new Star Wars: The Force Awakens film. 

a. Start Eclipse and create a new project. Call it LeanFTSeleniumSideBySide.

b. Add a reference to the Selenium JAR to your project.

c.  Add a new JUnitTestCase in your src directory.  Call your package mytests and call the class SeleniumTest.

d. Enter the code shown below in the SeleniumTest class.

e. To run the test, right click on the source file ( in the package explorer and select Run As->JUnit Test.



2. Add a LeanFT test to the project

The next step is to add a LeanFT test to the existing Selenium project.

  1. Right-click on our package (mytests) and select New > Other
  2. In the New dialog, select LeanFT JUnit Test Case, and press Next.


Give the test case the name: LeanFtTest and click Finish.


3. Add the LeanFT test content and then run both tests at once

Now we’ll add content to the LeanFT test case.  This test is similar to the Selenium test we created above, only this time we verify the name of the movie director instead of the movie release date.

  1. Enter the code shown below in the LeanFtTest class:
  2. Since we now have a single project with both Selenium and LeanFT tests, just right-click on the project, select Run As > JUnit Test and both test will be executed.


LeanFT-Selenium in One

In this section, we create a single test that contains both Selenium and LeanFT steps. This test is a combination of the two tests we wrote in the section above.

As Selenium can’t be attached to open browsers, the browser must be launched using Selenium. In addition, the browser should be launched with the LeanFT extension, to allow LeanFT to attach to this browser instance. This done in the setUp method, where we start the chrome driver with the LeanFT extension, and then use the LeanFT’s BrowserFactory.attach method, to attach to instance launched by Selenium.

From this point on we get all the capabilities of both LeanFT and Selenium on the same browser instance.

  1. Add another LeanFT JUnit Test Case to the project from above, so that we’ll already have the LeanFT template set up for us: Right-click on our existing package and select New > Other… > LeanFT JUnit Test Case.  Call the test case LeanFtAndSelenium.
  2. Insert the code shown below in the LeanFtAndSelenium class.
  3. To run just this test, right click on the class and select Run As-> JUnit Test.  (You can of course run all tests by doing the same on the package or project).


A note on the Test Report:

LeanFT automatically generates a rich html run report which enables an easy root-cause analysis of failures that occur while executing LeanFT test steps.

The LeanFT Reporter class also exposes an API that you can leverage to report the Selenium steps as well, and therefore have a single, complete report for the test.



This blog post shows how you can update your existing Selenium test projects to include LeanFT tests, and even combine both LeanFT and Selenium in a single test.

Thus, a project of Selenium tests can be migrated to LeanFT tests gradually, test-by-test, while your existing tests continue to function as usual.


If you would like to try LeanFT for yourself, take a look at the LeanFT Trial web site.


Thanks to Anton for providing this article!


Try LeanFT for yourself!


Feel free to leave a comment in the box below.


Functional Testing
  • First of all, I would like to thank you for sharing such a nice post.

    I am using LeanFT 14.51 with Selenium 3.141.59. Whenever I am trying to integrate LeanFT with Selenium I am getting the following error at the line where Agent.crx is being added using ChromeOptions.addExtensions method

    at test.LeanFtTest.setUpBeforeClass(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeBeforeAllMethods$6(
    at org.junit.jupiter.engine.execution.ThrowableCollector.execute(
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeBeforeAllMethods(
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(
    at$ForEachOp$OfRef.accept(Unknown Source)
    at$2$1.accept(Unknown Source)
    at java.util.Iterator.forEachRemaining(Unknown Source)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
    at Source)
    at Source)
    at$ForEachOp.evaluateSequential(Unknown Source)
    at$ForEachOp$OfRef.evaluateSequential(Unknown Source)
    at Source)
    at Source)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(
    at org.junit.platform.launcher.core.DefaultLauncher.execute(
    at org.junit.platform.launcher.core.DefaultLauncher.execute(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

    The interesting part is that if I execute the following lines in a purely Selenium project I don't get any error.

    ChromeOptions options = new ChromeOptions();
    options.addExtensions(new File("C:\\Program Files (x86)\\Micro Focus\\Unified Functional Testing\\Installations\\Chrome\\Agent.crx"));
    driver = new ChromeDriver(options);

    For my curiosity I  added the piece of code to add LeanFT chrome agent inside the setUpBeforeClass in a simple LeanFT Testing Project script and got the same error.Please suggest how to figure it out.

    LeanFT Error.PNG


  • When you say -

    The LeanFT Reporter class also exposes an API that you can leverage to report the Selenium steps as well, and therefore have a single, complete report for the test.


    Can you please show the steps, how to leverage the LeanFT report API for selenium tests?



    Sumit Gaur

  • I have tried integrating Seleniumscript with LeanFT.but I got Nosuchmethoderror while executing the same . Any suggestions where I am going wrong. Is that Attach method work with IE. please let me know 

  • They seem to be working fine together in terms of test execution, however I have been having some issues with the reporting side of things:

    - if I create a project using only LeanFT SDK, the "View Last Run Results" generates the full HTML report, but

    - if I try to add the selenium standalone jar to the project in order to run both at the same time, then only an xml version of the report is generated in the project folder and the "View Last Run Results" option is greyed-out.

    LeanFT Version 14.0.2816.0 installed as part of UFT 14.00 installation.

    The HTML report is available only if there is no selenium standalone jar.

    Have any of you encountered the above issue and knows how to resolve it?

    Any help will be very much appreciated.

  • I’m really excited about leanFT. I work on a modern web application but it integrates with thick client application that we can’t automate because Selenium is only for browsers. Now we are going to be able to leverage our existing Selenium/BDD framework with LeanFT with little rework. Well done HP - the only thing I would love to see is a way to add the LeanFT dependance in Maven so I can just add a dependency in our projects pom file.