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 ReferencesSetting up IntelliJ Project in leanft in Java
In this topic, we will see how to set up a LeanFT project in IntelliJ IDEA. We can create a new LeanFT project in 2 ways.- Using LeanFT templates
- Custom framework


package leanft;
import com.hp.lft.report.Reporter;
import com.hp.lft.sdk.ModifiableSDKConfiguration;
import com.hp.lft.sdk.SDK;
import org.junit.After;
import org.junit.Before;
import java.net.URI;
public class BaseTest {
@Before
public void test() throws Exception{
ModifiableSDKConfiguration config = new ModifiableSDKConfiguration();
config.setServerAddress(new URI("ws://localhost:5095"));
SDK.init(config);
Reporter.init();
}
@After
public void clean() throws Exception{
Reporter.generateReport();
SDK.cleanup();
}
}
Then we can write test methods as shown in below example.
package leanft;
import com.hp.lft.report.Reporter;
import com.hp.lft.report.Status;
import com.hp.lft.sdk.ModifiableSDKConfiguration;
import com.hp.lft.sdk.SDK;
import com.hp.lft.sdk.web.*;
import com.hp.lft.sdk.web.EditField;
import com.hp.lft.sdk.web.EditFieldDescription;
import org.junit.Test;
import java.net.URI;
import static org.junit.Assert.assertEquals;
public class ChromeTest extends BaseTest {
@Test
public void test() throws Exception{
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
try{
//Navigate to https://www.softpost.org/selenium-test-page/
browser.navigate("https://www.softpost.org/selenium-test-page/");
browser.sync();
}
catch(AssertionError ex){
//Report the Exception
Reporter.reportEvent("Exception","Test failed", Status.Failed, ex);
throw ex;
}
finally{
//Close the browser
browser.close();
}
}
}
Web development and Automation testing
solutions delivered!!