LeanFT with Java
Introduction Supported applications Installation of LeanFT and plugins for IDEs Installing browser Extensions LeanFT settings,Object identification Center Understanding LeanFT SDK API Installing the LeanFT jar files in Maven Repository Creating LeanFT Maven Project Creating LeanFT Project with Gradle and TestNG LeanFT Properties Setting up LeanFT project in IntelliJ IDEA Creating maven project with JUnit with LeanFT in Eclipse Creating maven project with TestNG in Eclipse Description programming Application model Using regular expression in property values First web application test Identifying the Web elements using XPATH and CSS Identifying objects using Visual Relational Identifiers – VRI Handling embedded browser control in Windows app Firing events on Web Elements using LeanFT Executing JavaScript in web page Automating standard windows application Automating Java Application Automating WPF applicationsAutomating SAP Application Synchronization in LeanFT Assertions in LeanFTLeanFT with Cucumber Keyword Driven frameworks Data Driven Frameworks Converting the UFT Object Repository to Application models in LeanFTChallenges of LeanFT automation Working with third party objects using Native Object properties and methods LeanFT common issues and solutionsLeanFT Java ReferencesCucumber in leanft in Java
We can integrate LeanFT tests with Cucumber BDD framework. If you know how to use JUnit with Cucumber, you will find it very easier to integrate LeanFT with Cucumber. Please follow below steps to integrate the LeanFT with Cucumber.- Create a maven project using LeanFT template
- Add cucumber and selenium dependency in POM.xml
- Write feature files and scenarios
- Write the step definitions for steps in Scenario
- Execute feature file
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
Then you have to create a feature file as shown in below example.
Feature: My feature
Scenario: My Scenario
Given I am on www.softpost.org page
Then I verify that title contains tutorial word
After that you can create step definitions as shown in below example.
package org.softpost;
import com.hp.lft.report.Reporter;
import com.hp.lft.sdk.ModifiableSDKConfiguration;
import com.hp.lft.sdk.SDK;
import com.hp.lft.sdk.web.Browser;
import com.hp.lft.sdk.web.BrowserFactory;
import com.hp.lft.sdk.web.BrowserType;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import org.junit.Assert;
import java.net.URI;
/**
* Created by Sagar on 23-07-2016.
*/
public class Steps {
Browser browser;
@Before
public void init() throws Exception{
ModifiableSDKConfiguration config = new ModifiableSDKConfiguration();
config.setServerAddress(new URI("ws://localhost:5095"));
SDK.init(config);
Reporter.init();
}
@Given("^I am on www\.softpost\.org page$")
public void i_am_on_www_softpost_org_page() throws Throwable {
browser = BrowserFactory.launch(BrowserType.CHROME);
browser.navigate("https://www.softpost.org");
}
@Then("^I verify that title contains tutorial word$")
public void i_verify_that_title_contains_tutorial_word() throws Throwable {
Assert.assertTrue(browser.getTitle().toLowerCase().contains("tutorial"));
}
@After
public void clean() throws Exception{
browser.close();
SDK.cleanup();
}
}
Web development and Automation testing
solutions delivered!!