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 ReferencesGenerating report in leanft in Java
Reports can be generated in 2 ways in LeanFT. Screenshots using Reporter and TestObject.GetSnapshot Video recordings of test execution using Microsoft expression encoder. By default, LeanFT creates the reports in RunResults folder in the root directory of Java project. But you can change that using ModifiableReportConfiguration class as shown in below example. You can also use below method to send your log messages to the report. Reporter.reportEvent
package leanft;
import com.hp.lft.report.*;
import com.hp.lft.sdk.Desktop;
import com.hp.lft.sdk.stdwin.Window;
import com.hp.lft.sdk.stdwin.WindowDescription;
import com.hp.lft.sdk.web.*;
import com.hp.lft.verifications.Verify;
import org.junit.Test;
import java.awt.image.RenderedImage;
public class ChromeReportTest extends BaseTest {
@Test
public void test() throws Exception{
ModifiableReportConfiguration reportConfig = ReportConfigurationFactory.createDefaultReportConfiguration();
reportConfig.setOverrideExisting(true);
reportConfig.setTargetDirectory("RunResults"); // The folder must exist under C: reportConfig.setReportFolder("myreportdirectory");
reportConfig.setTitle("My Report Title");
reportConfig.setDescription("Report Description");
reportConfig.setSnapshotsLevel(CaptureLevel.OnError);
Reporter.init(reportConfig);
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();
//set value in edit box
EditField firstName = browser.describe(EditField.class,new EditFieldDescription.Builder()
.id("fn").build());
firstName.setValue("Sagar");
//take screenshot
RenderedImage img = browser.getPage().getSnapshot();
if (firstName.getValue().equalsIgnoreCase("sagar"))
Reporter.reportEvent("Verify Editbox","Value is sagar", Status.Passed,img);
else
Reporter.reportEvent("Verify Editbox","Value is not sagar", Status.Failed,img);
}
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!!