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 Referencesgradle, testng project in leanft in Java
To create a LeanFT project with Gradle and TestNG, follow below steps. First of all, create a sample Gradle project in IntelliJ IDEA. Then add a libs directory under root directory and copy all LeanFT library files from C:\Program Files (x86)\HP\LeanFT\SDK\Java in it. Then ensure that your build.gradle file contains below configuration.
group 'org.softpost'
version '1.0-SNAPSHOT'
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'org.testng', name: 'testng', version: '6.9.10'
compile fileTree(dir: 'libs', include: '*.jar')
}
test {
useTestNG {
suites 'src/test/resources/testng.xml'
}
}
After this, create a sample TestNG test class and add LeanFT test as shown in below example. Notice that you will have to initialize the LeanFT SDK before starting the tests and clean up SDK at the end of tests. After this build your project and then run the tests.
package org.softpost;
import com.hp.lft.report.Reporter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.hp.lft.sdk.*;
import com.hp.lft.verifications.*;
import java.net.URI;
public class SimpleLeanFTTest {
@BeforeClass
public void beforeClass() {
}
@AfterClass
public void afterClass() {
}
@BeforeMethod
public void beforeMethod() {
try {
ModifiableSDKConfiguration config = new ModifiableSDKConfiguration();
config.setServerAddress(new URI("ws://localhost:5095"));
SDK.init(config);
Reporter.init();
}catch (Exception ex){
System.out.println("Exception occured " + ex.toString());
}
}
@AfterMethod
public void afterMethod() throws Exception {
Reporter.generateReport();
SDK.cleanup();
}
@Test
public void test() throws GeneralLeanFtException {
Verify.areEqual(22,22,"Verify that 22 == 22");
}
}
Web development and Automation testing
solutions delivered!!