Giter VIP home page Giter VIP logo

aws-device-farm-appium-tests-for-sample-app's Introduction

Appium Sample Tests for AWS Device Farm Sample App

This is a collection of example Appium TestNG tests written for the AWS Device Farm Android sample app. Please use these tests as a reference for your own AWS Device Farm Appium TestNG tests.

This test suite uses the Appium page model in order to separate the tests from the logic.

Android

Getting Started

  1. Follow the official Appium getting started guide and install the Appium server and dependencies.

    AWS Device Farm supports Appium version 1.7.2. Using a different version locally may cause unexpected results when running Appium tests on AWS Device Farm.

  2. In order to use 1.7.2, download Appium through NPM with this command:

    npm install -g [email protected]
    
  3. Verify that you have Appium installed with this command:

    appium -v
    

    You should get "1.7.2" as the output

Creating a new Java Appium Test Project Using Maven

  1. Create a new Maven project using a Java IDE. The example in this tutorial is for IntelliJ IDEA Community Edition.

  2. Set up your POM file using the official AWS Device Farm documentation for TestNG

    • You will need the following dependencies in your POM file

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

Running Your Tests Locally

First, make sure that you have followed all the steps in the Appium getting started guide.

Use the script start-appium-android.sh to run the Appium server locally. Once the server has started, run the TestNG tests within your IDE.

For example, if your package name is com.appium.example, your main activity name is .Activities.MainActivity, and the absolute filepath to your APK is ~/Desktop/appium/app.apk, you would run the following command.

appium --pre-launch --app-pkg com.appium.example --app-activity .Activities.MainActivity --platform-name Android --app ~/Desktop/appium/app.apk

Running Your Tests on AWS Device Farm

Step 1: Verify the Project Set-up

First Read the Device Farm documentation. Ensure that all the steps are completed and that your project and POM file are set up correctly.

Step 2: Go into your Maven Appium Directory

Go into your Appium Maven project directory in the terminal or command prompt.

Step 3: Package the Test Content

Run the following Maven command to package the test content.

mvn clean package -DskipTests=true

Step 4: Locate the zip-with-dependencies.zip file

Once the Maven command above is finished it will produce a "zip-with-dependencies.zip" file in your target folder. You will upload this file when creating a run on AWS Device Farm.

Examples For Android

Examples for Testing Specific Scenarios

Component Android Implementation Tests
Alerts: Toasts and Dialogs source code source code
Fixtures source code source code
Static Page: TextView source code source code
Login Page source code source code
Nested Views: Back and Up Navigation source code source code
Web Views
  • Hybrid Web Views (Not implemented)
  • Web View
An Expected Crash source code Not implemented

Strategies for Native Features

Feature Android Implementation Tests
Camera source code source code
Image Collection Grid source code source code
Scroll View source code source code
Out of View Content source code source code
Video source code source code

Examples for Testing Inputs

Component Android Implementation Tests
Checkbox source code source code
DatePicker source code Not implemented (not directly supported by Appium)
EditText source code source code
Gestures Input source code source code
Pull to Refresh source code source code
Radio Buttons source code source code
TimePicker source code Not implemented (not directly supported by Appium)
Toggle Button source code source code
Spinner Input source code source code
Buttons source code source code

Examples for Automated Navigation

Component Android Implementation Tests
Navigation Drawer source code source code
ViewPager source code source code

Tips and Tricks

Driver Configuration

Remember to set up your Appium driver correctly. AWS Device Farm takes care of the configuration for you, and you don't need to set any of the DesiredCapabilities when creating the driver. Refer to this example.

aws-device-farm-appium-tests-for-sample-app's People

Contributors

adriano-s avatar ahawker avatar appwiz avatar bjmorales avatar guneeshp avatar hunngu avatar hyandell avatar nikhil-dabhade avatar oonemo avatar scottgoldwater avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-device-farm-appium-tests-for-sample-app's Issues

Could not find the testng.xml in the jar file Error

My test fails on AWS build even after I followed all steps https://aws.amazon.com/premiumsupport/knowledge-center/xml-file-tests-jar-file-device-farm/
Question:

  1. Should I comment out Desire capabilities before running mvn clean package -DskipTests=true?
  2. when I check if the testng.xml exist in the jar tests here is what I get
0 Thu Feb 10 11:59:32 EST 2022 META-INF/
 128 Thu Feb 10 11:59:32 EST 2022 META-INF/MANIFEST.MF
1531 Thu Feb 10 11:59:30 EST 2022 LoginTest.class
   0 Thu Feb 10 11:59:32 EST 2022 META-INF/maven/
   0 Thu Feb 10 11:59:32 EST 2022 META-INF/maven/com.tesksio/
   0 Thu Feb 10 11:59:32 EST 2022 META-INF/maven/com.tesksio/Aws-Booksio/
3562 Thu Feb 10 11:56:42 EST 2022 META-INF/maven/com.test/Aws-Booksio/pom.xml
 126 Thu Feb 10 11:59:32 EST 2022 META-INF/maven/com.test/Aws/pom.properties

Does this mean that tesng is not available in the jar ?
image

How to control test case execution using testng.xml?

How to control test case execution using testng.xml?
Can we control the test case execution using testng.xml while executing appium test case on AWS device farm?

In my local system i am able to perform case execution using testng.xml, however it's not working on AWS device farm.

How to use priority in test cases?

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?

Farm has a different behavior than Junit

Hello,

I use Junit/Appium
For this test class :

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Class1 {
	@Test
	public void method1() {....}
       @Test
	public void method2() {....}

       @BeforeClass
        public static void setUp() {
            driver = new AndroidDriver(new URL(URL), getCapsAndroidEmulAut2());
       }
       @AfterClass
       public static void tearDown() {
            driver.quit();
    }
}

AWS Device Farm considers Class1 as a suite, each method as a class.
According to the results: Farm executes setUp() -> method1() -> tearDown() (this is the first suite)
Then a new suite is executed : setUp() -> method2() -> tearDown().

While the standard behavior of JUnit is Class1 is a test class, it execute : setUp() -> method1() -> method2() -> tearDown().

I want that AWS run tests as standard Junit.

Any help ?

getSize method does not work and throws an server internal exception

Hello,

I have observed certain issues when i uploaded my appium testng scripts to AWS device farm. Whenever the driver.manage().window().getSize() method is executed, the AWS gets the unknown server-side error. And also in device farm, whenever i tried to get the location of an element, it gets a null pointer exception.

Appium: 1.6.5
IOS : 10.3.2

Kindly provide any suggestions/workaround.

Thanks,
Mukund

Which test to be run first ? Where to configure this ?

I am new with maven and AWS.

As per the steps mentioned in AWS I am able to create .zip file successfully for my Junit project. Now I am not sure how or where I can configure the order of my tests. Lets say I have 5 test classes and I want to have a specific order for that,.

Kindly let me know how to proceed here ? Please do explain how AWS will take the tests and run.

Appreciate your input

Regards,
Adarsh E M

Test doesn't run on aws devices farm

I did pull the appium-tests-for-sample-app project,
and generated zip-with-dependencies.zip (i.e. typed mvn clean package -DskipTests=true).

I generated apk for sample-app and checked it worked on my device.

Add the apk to aws-farm, added tests as testng and run. Always same results: setup suite and teardown suite are done, the rest - failed. On the video from device farm I can see that the app didn't start at all. I tried even an empty test and same.

I can't find anything usefull in the logs.

Locally appium works fine. I had a lot of tests to run, but can't make it work in cloud.

I'm searching for the help or for any new idea (I spent the whole day on trying to run it).

Test results:

screen shot 2018-05-09 at 10 35 28

I can not run your project with Jenikins

Hi,

I clone this project and try to run using Jenkins with below settings attached file. I got fatal error. Below is the log message

at 137.5 KB/sec)
[INFO] Reading assembly descriptor: src/main/assembly/zip.xml
[INFO] Building zip: C:\automation\workspace\AndroidTest\target\zip-with-dependencies.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 57.281 s
[INFO] Finished at: 2015-10-28T06:41:50+00:00
[INFO] Final Memory: 26M/63M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\automation\workspace\AndroidTest\pom.xml to com.amazon.aws.adf.referenceapp.appium.test/Referenceapp-Appium-Test/1.0-SNAPSHOT/Referenceapp-Appium-Test-1.0-SNAPSHOT.pom
[JENKINS] Archiving C:\automation\workspace\AndroidTest\target\Referenceapp-Appium-Test-1.0-SNAPSHOT.jar to com.amazon.aws.adf.referenceapp.appium.test/Referenceapp-Appium-Test/1.0-SNAPSHOT/Referenceapp-Appium-Test-1.0-SNAPSHOT.jar
[JENKINS] Archiving C:\automation\workspace\AndroidTest\target\Referenceapp-Appium-Test-1.0-SNAPSHOT-tests.jar to com.amazon.aws.adf.referenceapp.appium.test/Referenceapp-Appium-Test/1.0-SNAPSHOT/Referenceapp-Appium-Test-1.0-SNAPSHOT-tests.jar
[JENKINS] Archiving C:\automation\workspace\AndroidTest\target\zip-with-dependencies.zip to com.amazon.aws.adf.referenceapp.appium.test/Referenceapp-Appium-Test/1.0-SNAPSHOT/Referenceapp-Appium-Test-1.0-SNAPSHOT.zip
channel stopped
FATAL: PermGen space
FATAL: PermGen space
Finished: SUCCESS
screen shot 2015-11-29 at 10 50 31 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.