Application model in leanft in Java

Application models are similar to the object repository in UFT. We can create a new application model in IntelliJ IDEA as shown in below image.Below image shows sample AppModel.tsrx file. In designer mode, we can add, remove objects in application model.

.tsrx file (Application model) in LeanFT

Below image shows how to add the objects to application model using Object Identification Center.Note that 2 files are created after new Application model is created.
  • YourModel.tsrx file -It is an XML file. We can also view this file in design mode where we can add and edit the objects.
  • YourModel.java file containing the code representing the objects in the application model.
Below code shows how to use the application model to write the tests.
 
package leanft;

import com.hp.lft.sdk.web.Browser;
import com.hp.lft.sdk.web.BrowserFactory;
import com.hp.lft.sdk.web.BrowserType;
import org.junit.Test;

/**
 * Created by Sagar on 22-07-2016.
 */
public class AppModelTest extends BaseTest{

    @Test
    public void test1() throws Exception{
        Browser browser = BrowserFactory.launch(BrowserType.CHROME);
        browser.navigate("https://www.softpost.org/selenium-test-page/");
        AppModel model = new AppModel(browser);

        model.SeleniumTestPage().firstName().setValue("Sagar");
    }
}

Another important point to note is that we can use Application model together with description programming to identify the objects as shown in below sample code. Note that we have used SeleniumTestPage object from the Application model but we have used description programming to identify the EditField object inside page.
 
model.SeleniumTestPage().describe(EditField.class,new EditFieldDescription.Builder()
.id("fn").build()).setValue("Salunke");                    

Complex problems, Simple Solutions