Record and run LeanFT tests remotely using StormRunner Functional

This article describes how to record and run your LeanFT test remotely in your SRF lab.

Configure the connection to SRF

To configure the connection from LeanFT to SRF:

1. On the SRF settings page, generate a client ID and secret to use when accessing SRF.

2. In LeanFT, open your LeanFT Runtime Engine Settings dialog box, and select the Labs tab.

Define your SRF settings under StormRunner Functional Settings.


Define your settings as follows:

Server address The URL of your SRF tenant.

For example:

Client ID / Client secret The client ID and secret you generated to connect to SRF.
Use proxy Select to use a proxy to access SRF, and then also define your proxy settings in the fields below.
Do not validate certificate By default, LeanFT employs Full SSL (Strict). Select this option to ignore certificate errors.
Show remote access window when a mobile test runs Select to enable watching your test runs on the mobile devices in the SRF remote access window.

Note: If you select this option, and your device connector uses a self-signed certificate, then the first time a test runs you will receive the following certificate message:

The attempt to connect to <connector URL> has failed

To fix this issue, add the connector’s self-sign certificate to your machines trusted certificate storage.

After configuring your certificate you should restart the LeanFT engine.

Click Verify to check your connection.

Edit your LeanFT test

Edit your test to enable running it in SRF.

Specifically, modify your test script so that it launches browsers and locks mobile devices that are allocated by SRF in the cloud, rather than local browsers and devices.

Use the following when editing your test:

SrfLab class

Use the SrfLab class to launch your browser or lock a mobile device in SRF.

Provide the SrfLab class with description objects for your browser or device, defining the capabilities you would like to use as your test environment.


Use the LeanFT SDKs to define your test object and write your script, just as you would when running a test locally.

Supported capabilities for LeanFT

Use capability code to define SRF feature values, such as test tags, or the names displayed in test results, as well as environment settings.

Releasing SRF environments

We recommend calling the releaseEnvironment method of the SrfLab class at the end of your test to unlock a device and release the browser environment.

Add visual testing steps

Integrate your LeanFT test with both SRF and Applitools.

To do this, add code as needed to define your Applitools visual testing steps and environment variables.

Design mobile tests on SRF mobile devices

Use LeanFT’s Test Recorder and Object Identification Center on mobile apps, on SRF-provisioned mobile devices.

Make sure that the connection between LeanFT and SRF is configured.

1. From your IDE menu, click LeanFT > Launch a StormRunner Functional Device.

The SRF Mobile Lab window opens.

2. Select the device on which you want to spy or record.

Once selected, the device will be locked.

3. To spy, open the required app on the device (or install it if it is not already installed). You can start recording either before or after you open the app.

4. From your IDE menu, open the Object Identification Center or Test Recorder and use them as you would typically.

5. When you are done using the device, close the Mobile Lab window to release the device.

While the device is locked, you can run your test on it for debugging purposes. A run report will be created in LeanFT, but will not be created in SRF.

Run your test and view results

Run your test in SRF just as you would locally.

Snapshots in run results are affected by snapshot levels set in the script, as for other LeanFT tests.

Test results are displayed both in the LeanFT run report, and in SRF.

LeanFT code samples for remote testing

LeanFT Java code samples

Launch the latest version of Chrome in a Windows 7 machine

Browser browser = SrfLab.launchBrowser(BrowserType.CHROME);

Launch IE 11 on a Windows 10 machine and set the SRF test name to be shown in the RESULTS tab

· Provide a predefined object:

BrowserDescription bd = new BrowserDescription();

bd.setType(BrowserType.INTERNET_EXPLORER); //or: bd.set(“type”, BrowserType.INTERNET_EXPLORER) or: bd.set(“type”, “INTERNET_EXPLORER”)

bd.set(“version”, “11”);

bd.set(“osType”, “Windows”);

bd.set(“osVersion”, “10”);

bd.set(“testName”, “My LeanFT web test”);

Browser browser = SrfLab.launchBrowser(bd);

· Define capabilities using the Builder syntax:

Browser browser = SrfLab.launchBrowser(new BrowserDescription.Builder().type(BrowserType.INTERNET_EXPLORER).set(“version”, “11”).set(“osType”, “Windows”).set(“osVersion”,”10″).set(“testName”, “My LeanFT web test”).build());

Lock a device in SRF

· Provide a predefined object:

DeviceDescription dd = new DeviceDescription();

dd.setOsType(“Android”); //or: dd.set(“osType”, “Android”)

dd.setOsVersion(“5.02”); //or: dd.set(“osVersion”, “5.02”)

dd.set(“testName”, “My LeanFT mobile test”);

Device device = SrfLab.lockDevice(dd);

· Define capabilities using the Builder syntax:

Device device = SrfLab.lockDevice(new DeviceDescription.Builder().osType(“Android”).osVersion(“4”).set(“testName”,” My LeanFT mobile test”).build());

· Define capabilities in the SrfLab class, calling previously mapped properties:

Map<String, Object> props = new HashMap<>();

props.put(“osType”, “Android”);

props.put(“osVersion”, “5.02”);

props.put(“testName”, ” My LeanFT mobile test “);

Device device = SrfLab.lockDevice(DeviceDescription.fromMap(props));

Launch a browser in an SRF mobile device

First, lock an SRF device, and then launch your browser by passing the device object to theBrowserFactory.launch method.

Browser browser = BrowserFactory.launch(BrowserType.Chrome, device);

Release the SRF environment at the end of your test

· Release a web environment


· Unlock a device


LeanFT JavaScript code samples

Launch the latest version of Chrome in a Windows 7 machine

LFT.SrfLab.launchBrowser(“Chrome”).then(function (b) { //or: Web.BrowserType.Chrome instead of “Chrome”

browser = b;


Launch IE 11 on a Windows 10 machine and set the SRF test name to be shown in the RESULTS tab


type: Web.BrowserType.IE, //or: type: “IE”

version: “11”,

osType: “Windows”,

osVersion: “10”,

testName: “My LeanFT web test”

}).then(function (b) {

browser = b;


Lock a device in SRF


osType: “Android”,

osVersion: “5.02”,

testName: “My LeanFT mobile test”

}).then(function(d) {

device = d;


Release the SRF environment at the end of your test

· Release a web environment


· Unlock a device


Full test – Advantage Online Shopping

The following example tests the Advantage Online Shopping site.

var LFT = require('leanft');
var SDK = LFT.SDK;
var Web = LFT.Web;
var whenDone = LFT.whenDone;
var expect = require('leanft/expect');
describe('Example of LeanFT execution burst test in SRF', function () {
 var browser;
 before(function (done) {
 beforeEach(function (done) {
 //The following are examples of available capabilities when launching a browser in SRF.
 osType: "windows",
 osVersion: "8.1",
 type: "chrome",
 //version: "58",//Specify a specific number or define as the latest version, as follows:
 version: "latest",
 release: "0.95",
 build: "1234",
 screenResolution: "800x600",
 testName: "Demo_Burst_Test_LeanFT_JS"
 .then(function (b) {
 browser = b;
 it('should validate the price of the chosen item', function (done) {
 var searchAdvantageonlineshopping = browser.$(Web.Edit({
 name: "WebEdit",
 tagName: "INPUT",
 type: "text"
 var boseSoundlinkBluetooth = browser.$(Web.Link({
 tagName: "A"
 var itemPrice = browser.$(Web.Element({ xpath: "//DIV[@id="Description"]/H2[1]", className: "roboto-thin screen768 ng-binding", tagName: "H2" }));
 //Sample checkpoint (expects) validation:
 afterEach(function (done) {
 if (browser) {
 after(function (done) {

LeanFT C# code samples

Release the SRF environment at the end of your test

· Release a web environment


· Unlock a device


Full test – Advantage Online Shopping

The following example tests the Advantage Online Shopping site using the LeanFT NUnit3 template.

using System;
using NUnit.Framework;
using HP.LFT.SDK;
using HP.LFT.Verifications;
using HP.LFT.SDK.Web;
using System.Text.RegularExpressions;
namespace LeanFtTestProject1
 public class LeanFtTest : UnitTestClassBase
 static BrowserDescription brDesc;
 static IBrowser browser;
 String categoryToFind = "speakers";
 String itemToFind = "Bose Soundlink Bluetooth Speaker III";
 String expectedPrice = "$269.99";
 static String userName = "<username>";
 static String userPassword = "<password>";
 [OneTimeSetUp]public void TestFixtureSetUp()
 var brDesc = new BrowserDescription();
 //example of the different capabilities that can be used when launching a browser in SRF.
 brDesc.Type = BrowserType.Chrome;
 brDesc.Set("version", "58");
 brDesc.Set("osType", "windows");
 brDesc.Set("osVersion", "8.1");
 brDesc.Set("release", "0.95");
 brDesc.Set("build", "1024");
 brDesc.Set("testName", "LeanFT Burst C# Online Shopping");
 brDesc.Set("resolution", "800x600");

 browser = SrfLab.LaunchBrowser(brDesc);
 [SetUp]public void SetUp()
 // Before each test
 [Test]public void ValidatePriceOfChosenItem()

 browser.Describe<IEditField>(new EditFieldDescription
 Type = @"text",
 Placeholder = @"Search",
 TagName = @"INPUT",
 Name = @"WebEdit"

 browser.Describe<IWebElement>(new WebElementDescription
 AccessibilityName = string.Empty,
 TagName = @"svg",
 InnerText = string.Empty,
 Index = 10

 browser.Describe<IWebElement>(new WebElementDescription
 TagName = @"A",
 InnerText = "Bose Soundlink Bluetooth Speaker III"

 String itemPrice = browser.Describe<IWebElement>(new WebElementDescription
 XPath = @"//DIV[@id=""mobileDescription""]/H2[1]",
 ClassName = @"roboto-thin ng-binding",
 TagName = @"H2"

 Assert.AreEqual("$269.99", itemPrice);
 public void TearDown()
 // Clean up after each test
 [OneTimeTearDown]public void TestFixtureTearDown()
 // Clean up once per fixture

Leave a Comment