LeanFT ApplicationModel project setup and overview on ECLIPS.

Hello, lets look at how to create your first test using application model with LeanFT step by step.

Once you install and configure the LeanFT for eclips ( LeanFT quick setup for ECLIPS IDE) you can create new ApplicationModel project.

  • Select  file -> new -> Project in ECLIPS IDE.
  • Select ApplicationModel Project
  • newProject
  • you can opt out Maven project or you can choose maven depending on your project requirement, I am going ahead without maven since it is just for demo.
  • CAUTION : If you are creating without maven, then you might have to add decencies manually.
  •       MavenProject
  • Give a name to project and give a package name (example com.demo) After click on finish you should see project default structure like below.
  • ProjectDefaults
  • Now if you see the com.demo it is disabled and it contains the application model which is nothing but object structure or object repository in old UFT terms.
  • ApplicationModel
  • As you see you have Hat icon and + icon on the top right side of the Application Model which indicates Inspecting and  Adding the objects to Object Repository.
  • Lets look at test case where we want to open googole site and search for LeanFT.
  • Lets first make sure in the system tray  LeanFT runtime Engine is running. As discussed in earlier post, leanFT runtime engine is responsible for the identifying the objects and running the created tests.
  • SystemTray
  • We must select web engine in the UFTRuntime settings so that objects will be identified as web objects. Right click on the icon in system tray and select Web as option, once you do it Runtime Engine will automatically restarts. If not do it manually and check if all objects are identifying as web objects.
  • DefineENgine.PNG
  • To create test first we need to define UI objects and pages you want to test on.
  • Lets click on Had Icon to identify the objects, and use add icon (+CUBE icon) on the inspect screen to add objects. Add text box object and google search button too.
  • googleTextBox
  • Once you add objects, you should see Application Model as follows.
  • AddedObjects
  • Notice few things here
    • WebPages – Hierarchic objects
    • WebElements – Child elements in the WebPages.
  • In the left hand side, you see name and Code name, Code name is what we use to invoke the object, it is like function that returns this object.
  • LeanFT automatically creates the associated page classes and creates objects in ApplicationModel.java class.
  • Do not modify this class as code gets regenerated everytime you update ApplcationModel.
  • ApplicationModel_Class
  • Now lets look at test case and some of the jar files that are needed to run the test cases.
  • The ApplicationModel.java has all methods that returns the UI objects with code names.
  • TestClass can make use of it and create test cases. Following is the way to generate the test case.
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.Test;
import com.demo.ApplicationModel;
import com.hp.lft.report.Reporter;
import com.hp.lft.sdk.*;
import com.hp.lft.sdk.web.*;
import com.hp.lft.sdk.GeneralLeanFtException;
import com.hp.lft.sdk.web.Browser;
import com.hp.lft.sdk.web.BrowserFactory;
import com.hp.lft.sdk.web.BrowserType;

public class TestClass { 
@Test 
public void test() throws Exception 
{  
Browser browser = BrowserFactory.launch(BrowserType.CHROME); 
browser.navigate("https://google.com"); 
ApplicationModel app = new ApplicationModel(browser); 
app.googlePage().searchEditField().setValue("LeanFT"); 
app.googlePage().googleSearchButton().click(); 
}
}

in the above @Test method, you can see application model app is being created as object.

After creating the “app” object, the first thing model returns is pages, and each page returns all objects in it. You can invoke the object with their code names and perform actions on it.

Going back to import statements , there are are lot of them, along with already loaded jar files. LeanFT requires these jar files to include in the test to avoid sdk loading issues.

additionalJars

After adding you project should look like below.

AllJars

Now you are ready to start the execution of created test.

When you run your tests you might get following exception for loading sdk. Also you might not see view las run results enabled.

SDK Load Issue

to avoid above issues, include loading sdk and generating report part through code. I have got this from micro focus site after running around few hours. Please find below link for detailed explanation. I have added code from same to my test and it worked like charm.

load SDK

@Test public void test_modified() throws Exception 

{ 

//code to resolve sdk lodaing issues 
ModifiableSDKConfiguration config = new ModifiableSDKConfiguration(); 
SDK.init(config); 
Reporter.init();   

Browser browser = BrowserFactory.launch(BrowserType.CHROME); 
browser.navigate("https://google.com"); 
ApplicationModel app = new ApplicationModel(browser); 
app.googlePage().searchEditField().setValue("LeanFT");
 app.googlePage().googleSearchButton().click(); 

//Code to generate report and cleanup 
Reporter.generateReport();         
SDK.cleanup();
}

Now the issue got resolved and I got the report link enabled after I run the script. if it is not enabled we can get the latest report from RunResults directory. Sample leanFT report for the above test will look like below.

LeanFTReport

This is how we can quickly setup the project for leanFT and execute the tests for Application model.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s