Sample project for Mobile app testing using Appium and Aws device farm

i am new to appium and AWS devicefarm, i created a java maven project in eclipse and write a sample scripting for my application testing. The Script written for my application works fine in my physical test mobile and Aws device farm. and i created the zip file for the aws device farm using the below command

mvn clean package -DskipTests=true

i also tried the sample application provided by aws and it works fine in my aws,the sample i tried is from the below link https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app

The code i tried is given below

package *******;

import io.appium.java_client.android.AndroidDriver;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;

public class ******Base {
     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();

                //relative path to apk file
                final File classpathRoot = new File(System.getProperty("user.dir"));
                final File appDir = new File(classpathRoot, "src/test/resources/apps/");
                final File app = new File(appDir, "******.apk");

                driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);        
                driver.manage().timeouts().implicitlyWait(500, TimeUnit.SECONDS);

        }

        //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();
        }

    }

Quickpay.java

   package *****;

import io.appium.java_client.MobileBy;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;    

public class QuickPay extends *****Base {



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

                 //Select Language,click on login redirect to Login page
                private static int DEFAULT_TIMEOUT = 30; // seconds
                 @Test
                 public void T1a_Landingpage() {
                     new WebDriverWait(driver,DEFAULT_TIMEOUT).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-21')]"))).click();
                     //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();    
                 }
}

POM.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd https://mvnrepository.com/artifact/io.appium/java-client">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.aws.appium</groupId>
  <artifactId>appium-android-test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>ReferenceAppAppiumTests</name>
    <url>http://maven.apache.org</url>

    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>3.1.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>zip-with-dependencies</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>src/main/assembly/zip.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
Zip.xml

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>zip</id>
  <formats>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>./</outputDirectory>
      <includes>
        <include>*.jar</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>./</outputDirectory>
      <includes>
        <include>/dependency-jars/</include>
      </includes>
    </fileSet>
  </fileSets>
</assembly>

This may Hepful|||||||||||||||||||

Can we use priority in our test cases?
I am executing test cases on AWS device farm, in my local system it’s working fine. However, on device farm it’s not working as per given priority.

Can we handle test case execution using testng.xml file on AWS device farm?

Try to use Page object Model