With AWS Device Farm, you can quickly get started testing your Android, iOS, and FireOS apps on real devices in the AWS cloud. Simply upload your app, choose your test framework and the devices you want to test your app on, and start your test run. AWS Device Farm will provide the results of your tests including pass / fail status, logs, performance metrics, and screenshots.
The objective of this three-part series is to walk through step-by-step how to get started testing an iOS app with AWS Device Farm. The test automation framework we will be using is Appium and we will write our test cases using the TestNG framework. We will not be building an iOS app as part of this walkthrough. However, to follow along with this post, a sample iOS app is available for download here.
At the end of this series, you will have the knowledge required to test an iOS app with AWS Device using Appium and TestNG.
For this example, the tools and versions listed below were used. It is assumed you have these tools installed on your machine beforehand and that you have an AWS Account.
Eclipse IDE Mars was used for this tutorial.
Xcode 7.0 We will use a sample, unsigned iOS app called “ToDoList.ipa” that you can download here.
Appium 1.4.8 If you have not worked with Appium before, please review the Appium documentation before moving ahead. We will be using the Appium GUI for this tutorial. Please install the latest version of the Appium GUI.
AWS Account and IAM User creation Follow steps under the Setting Up section of the AWS Device Farm documentation.
Appium is a test automation framework that executes your test suite across both iOS and Android apps without you having to further modify your app or create separate test suites for the same app. Appium is able to provide this capability by utilizing Selenium WebDriver, which follows a client-server protocol. Appium uses Selenium WebDriver to be able to receive commands from a client running your tests and respond to those commands with a response over HTTP. This follows a request / response paradigm in which requests are the commands being sent to the Appium server and responses are being received by the client via WebDriver.
Tests for an iOS or Android app are written in a WebDriver-supported programming language. Appium provides client-side libraries for many languages.
An Appium server is launched after installation and configuration on the test machine.
The tests are initiated on a client machine.
Appium will begin receiving commands from the client (the machine running your tests) and execute those commands (your test emulating user actions with your app) on an emulator or real device.
Now that we have walked through the prerequisites and an overview of Appium, let’s get started building out our test cases for the sample iOS app you have downloaded.
Launch Eclipse and create a new Java project to begin writing your test cases by selecting File -> New -> Java Project.
Create two source folders: src/main/java and src/test/java. Within each source folder, create a package in which you will eventually create your TestNG test class. Your project structure should look similar to the below.
Configure the build path for each source folder by right clicking the source folder and selecting ‘Configure Build Path.’ Ensure you have selected the Java Build Path option from the left hand menu and you are on the Source tab. Check the ‘Allow output folders for source folders’ option.
For src/main/java -> the output folder is target/classes.
For src/test/java -> the output folder is target/test-classes.
The build paths for your source folders should look similar to the folders in the image below.
Download the Selenium Client & WebDriver Language Bindings for the language of your choice. For this tutorial, we will be using Java. Downloads are available at: http://docs.seleniumhq.org/download/.
Once you have saved and unzipped the Selenium dependencies to your machine, right-click the Java project created in Step 1 and go to Properties.
Select Java Build Path in the left-hand menu and ensure you are on the Libraries tab. Select ‘Add External JARS’ and navigate to the location of your Selenium jar files.
To install TestNG in Eclipse, go to Help -> Eclipse Marketplace -> Search for TestNG and Install.
Right click on the project created in Step 1 and go to Properties.
Select Java Build Path in the left-hand menu and ensure you are on the Libraries tab. Select the ‘Add Library’ button on the right.
Select TestNG -> Next -> Finish.
Select ‘Apply’ and then click OK.
Download the Appium client library for Java and add the jar file to the project you created in Step 1. Follow steps as performed when adding the Selenium jar files.
Once all referenced libraries have been added to your Java project, your project structure should look similar to the image below.
To capture the user interface elements and interactions in the TestNG test suite, Appium Inspector was used. To do this yourself, you can launch the Appium GUI and select the iOS Settings.
For the App Path, navigate to the location of your .app file.
Ensure you check the Force Device option and choose a device.
Ensure a Platform Version is selected.
Click the icon with the magnifying glass to launch the Appium Inspector.
Select Use External NodeJS Binary to "Your local node bin folder path"
Select Use External Appium Package to "Your Appium Local clone folder path"
You should now have your environment set up, a sample iOS app that you downloaded, and an Eclipse project with your TestNG tests. With this you can run your test suite locally with Appium and validate your tests. Join us in Part 2 where we will walk through how to prepare your TestNG test suite for uploading to AWS Device Farm. Finally, in Part 3 we will run the tests we’ve created in the AWS Cloud with AWS Device Farm. We are always interested in your feedback, comments, and questions so please reach out to us in the comments section below or in our developer forum.