ExecuteAutomation

Page Object model with Appium

In this post we will discuss how to create and work with Page Object Model (POM) in Appium. We have already discuss page POM in greater detail while discussion Selenium framework design and development articles and videos, hence we will change our gears here to focus directly on the coding part of Page Object Model in appium rather talking about its theories. Here is the complete code for Page Object Model (POM) in appium Code for Page
public class CalcAppPage {

	public CalcAppPage(AppiumDriver driver) {
		PageFactory.initElements(new AppiumFieldDecorator(driver), this);
	}

	@AndroidFindBy(id = "edtno1")
	public WebElement txtNum1;

	@AndroidFindBy(id = "edtno2")
	public WebElement txtNum2;

	@AndroidFindBy(id = "txtResult")
	public WebElement txtResult;

	public void Add(String num1, String num2) {
		txtNum1.sendKeys(num1);
		txtNum2.sendKeys(num2);
	}

	public boolean VerifyResult(String result) {
		if (txtResult.getText().equals(result))
			return true;
		else
			return false;
	}

}

Code for Test 
@Test
	public void SimpleTest() {

		CalcAppPage calPage = new CalcAppPage(driver);

		calPage.Add("20", "30");

		if (calPage.VerifyResult("50"))
			System.out.println("PASSED Test");
		else
			System.out.println("FAILED Test");

	}
Here is the complete video of the above discussion Thanks for reading the post and watching the video !!! Please leave your comments and let me know if there is anything I should update in this post. Thanks, Karthik KK