I changed coding format to the Pageobject model
Fbase.java
public class Fbase {
protected AndroidDriver driver;
protected WebDriverWait wait;
//before Test Annotation makes a java function to run every time before a TestNG test case
@BeforeTest
protected void createAppiumDriver() throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "0123456789ABCDEF");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
capabilities.setCapability(CapabilityType.VERSION, "5.0");
//capabilities.setCapability(CapabilityType.VERSION, "5.0.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.*****");
capabilities.setCapability("appActivity", "com.*******");
capabilities.setCapability("unicodekeyboard", true);
capabilities.setCapability("resetkeyboard", true);
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(driver, 300);
wait.until(ExpectedConditions.elementToBeClickable(By.className("android.widget.FrameLayout")));
}
//After Test Annotation makes a java function to run every time after a TestNG test case
@AfterTest
public void afterTest(){
//quit the driver
driver.quit();
}
}
and the page.java is
public class QuickPay extends Fbase {
/*--------------------------------Enter pin Starts---------------------------------*/
//Enter 4 digit pin to login
@Test
public void T4a_Login() {
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-1')]")).sendKeys("1234");
}
/*--------------------------------Enter pin Ends---------------------------------*/
/*QuickPay Starts*/
//Click on quick pay
@Test
public void T5a_QuickpayF() {
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-30')]")).click();
}
//Enter account number , Amount and click quick pay
@Test
public void T5b_QuickpayF() {
driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-229')]")).sendKeys("10015000301404");
driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-236')]")).sendKeys("50");
driver.hideKeyboard();
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-34')]")).click();
}
//Click on confirm button
@Test
public void T5c_QuickpayF() {
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-38') and @index='0']")).click();
}
//Enter pin for Quick k
@Test
public void T5d_QuickpayF() {
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-45') and @index='1']")).click();
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-46') and @index='2']")).click();
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-47') and @index='3']")).click();
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-48') and @index='4']")).click();
}
//Click on home for redirect to Home page
@Test
public void T5e_QuickpayF() {
System.out.println("testtt");
driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-60')and @index='0']")).click();
System.out.println("rt");
}
/*--------------------------------Quick pay to t Ends---------------------------------*/
}
Please correct me with this code has any issue