Looking for a good Coding format in Appium-java for Full app testing

I am new to Appium, In my code I have given required desired capabilities and wrote test case that is working fine. I tired each scenario (eg login,Mobile recharge etc…)in separate class . Test cases in a login page into different functions and provide function names in alphabetical order… can i know i was doing my scrpting in correct format

Code i tried is given below

package ********;

import io.appium.java_client.android.AndroidDriver;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.ElementNotVisibleException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;    //@AfterTest annotated method will be executed when all @Test annotated methods completed its execution
import org.testng.annotations.BeforeTest;   //@Before Test annotated method will be executed before any @Test method
import org.testng.annotations.Test;         //@Test annotation describes method as a test method or part of your test

public class Login {

    //WebDriver driver;
      AndroidDriver driver;
      Dimension size;

      //Setup to Launch the app
      @BeforeTest
      public void setUp() throws MalformedURLException {

      DesiredCapabilities capabilities = new DesiredCapabilities();
      capabilities.setCapability("deviceName", "0123456789ABCDEF");
      capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
      capabilities.setCapability(CapabilityType.VERSION, "5.0");
      capabilities.setCapability("platformName", "Android");
      capabilities.setCapability("appPackage", "*******");
      capabilities.setCapability("appActivity", "com.********e");
      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(30, TimeUnit.SECONDS);
      WebDriverWait wait = new WebDriverWait(driver, 3047230);
      wait.until(ExpectedConditions.elementToBeClickable(By.className("android.widget.FrameLayout")));

     }  

//Login Starts   

/*--------------------------Select the language and click on Login Starts-----------------*/    

             //Select Language,click on login redirect to Login page
             @Test
             public void T1a_Landingpage() {
                 driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-21')]")).click(); //Open drop down menu
                 driver.findElement(By.name("English")).click(); //Select from drop down
                 driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-element-26')]")).click();

             }  

/*--------------------------Select the language and click on Login Ends--------------------*/

/*--------------------------------Login details page Starts---------------------------------*/  

             //Click on Help content in Login page
             @Test
             public void T1b_HelpContent() {
                 driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'fedhelpbtncontainer')]")).click();
                 driver.findElement(By.xpath("//android.view.View[@content-desc='OK']")).click();    
             }

             //Enter Mobile Number, Account number and Pin
             @Test
             public void T1c_Enterdetails() {
                  //driver.findElement(By.xpath("//android.widget.EditText[@text='Mobile Number']")).sendKeys("8129497946");
                 //driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-65')']")).click(); 
                 driver.findElement(By.name("Account Number")).sendKeys("15125000213700");
                 driver.hideKeyboard(); 
                 driver.findElement(By.name("PIN")).sendKeys("1234");
                 driver.hideKeyboard(); 
                 driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-6')]")).click();         
             }  

/*--------------------------------Login details page Ends------------------------------*/

/*--------------------------------Activate page Starts---------------------------------*/

             //Click to Activate
             @Test
             public void T1d_Activate() {            
                driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-7')]")).click();      
             } 


/*--------------------------------Activate page Ends---------------------------------*/

/*--------------------------------Enter pin Starts---------------------------------*/

             //Enter 4 digit pin to login
             @Test
             public void T1e_Login() {      
                driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-1')]")).sendKeys("1234");
             } 

/*--------------------------------Enter pin Ends---------------------------------*/

//Login End   


    @AfterTest
 public void End() {
 System.out.println("End");
     driver.quit();
 }
    }
  1. create BaseTest class and move there all “@AfterTest”, “@BeforeTest” …
  2. Login class should extend BaseTest
  3. move all search elements into Pages.

Example: PageFactory PageObjectModel issues

So the way in which i coded is completely wrong?

also the third point is also confusing? please help

  1. “So the way in which i coded is completely wrong?” - for writing multiple tests and support them your way is wrong.
  2. see example i gave with abstract class “Page”

Thankz for the time. The following reference may also help me
https://help.testobject.com/docs/guides/appium-advanced-setup/

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