1) After you download and install LeanFT, don't forget to check the option for Eclipse (if you are using Java) which will install the necessary templates and also deploy all plugins required.
![alt text][1]
The installation will add the following directory to your system PATH:
*C:Program Files (x86)HPLeanFTbin*
2) Browser Setup
A few setting(s) you should perform for different browsers before we dive into the code:
**Firefox**
In the Firefox browser menu, select Add-ons and then click Extensions. Drag the *Agent.xpi* file from the %LeanFT%InstallationsFirefox folder to the Firefox Extension page and click 'Install now'.
**Chrome**
If you are testing against Chrome, ensure the LeanFT plugin is enabled from *Chrome Settings -> Extensions*
**Internet Explorer**
With IE, go to *Settings -> Manage Addons* where HP Functional Testing Agent must be enabled.
3) LeanFT Test
HP provides a LeanFT-JUnit template which would perform all of the initializations. We are showing how to use the template but also there is a way on how to perform the configuration without it, so you don't have to use a template or even extend the UnitTestClassBase
If you use the LeanFT-JUnit template or extend from UnitTestClassBase, all required configurations would already be taken care of. No extra steps required. UnitTestClassBase extends from UnitTestBase.
Example of the project structure:
![alt text][2]
Sample code using the template:
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import unittesting.UnitTestClassBase;
import com.hp.lft.sdk.web.*;
public class LeanFtMercuryTours extends UnitTestClassBase {
@BeforeClass
public static void beforeClass() throws Exception {
globalSetup(LeanFtMercuryTours.class);
}
@AfterClass
public static void afterClass() throws Exception {
globalTearDown();
}
@Test
public void test() throws Exception {
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
browser.navigate(''http://newtours.demoaut.com'');
browser.describe(EditField.class, new XPathDescription(''//input[@name='userName']'')).setValue(''test'');
browser.describe(EditField.class, new XPathDescription(''//input[@name='password']'')).setValue(''test'');
browser.describe(Image.class, new XPathDescription(''//input[@name='login']'')).click();
browser.close();
}
}
Running the above code will generate the below report in your projectFolder/RunResults directory
You can find some additional information in regards to this in the following article:
http://leanft-help.saas.hp.com/en/latest/HelpCenter/Content/HowTo/SetupLeanFT.htm
Finally, it is important to keep in mind that there are a few limitations with LeanFT (Please check the complete documentation):
* The LeanFT Eclipse plugin currently does not provide the application model functionality.
* The LeanFT HTML Report cannot be viewed in a Firefox browser.
* When using the Highlight option in the application model for a test object with VRI objects defined, the highlight operation succeeds only if exactly one object matches the description (including the VRI definitions). If multiple objects match, nothing is highlighted. Workaround: Use the VRI Preview option to check the description.
[1]: /storage/temp/315-img1.jpg
[2]: /storage/temp/316-im2.jpg