The defining characteristics of a useful mobile testing service in the cloud are: instant access to a large number of real devices, ability to run parallel tests, excellent reporting, ability to configure the device state, and little to no modifications to your existing test setup.
Working with our most successful mobile customers, we noticed that they use a small set of dedicated physical devices or emulators during the app development and test code authoring phase. Thereafter, when they are closer to the release, they access a larger fleet of devices to get extensive market coverage. In addition, their continuous integration (CI) tools need access to a set of devices to run their regression tests on every check-in and on a nightly or daily basis.
AWS Device Farm provides access to a large fleet of real devices in the public fleet. These devices can be used for the release regression tests that are close to release. They can also be used with a CI system like Jenkins, using the Device Farm Jenkins plugin.
One of things that was missing was the ability to provide these devices during development or during the test code authoring phase. Moreover, if there was a testing framework that you used locally that was not officially supported on Device Farm, you could not use these devices. So we created direct device access in Device Farm.
Direct device access makes the most powerful resources at our disposal, devices, available to you locally. It works only with private devices. Private devices are dedicated to you and you get more granular control on these devices. This level of control becomes important when using any physical device during app development. We enable access to this feature through a client application running on a local host machine.
1. This feature works with private devices only so you first need to buy them. You can get started on that using this link.
2. Make sure you are not on a proxy network.
3. Download and configure the AWS CLI.
4. Download and install the client application for this feature for macOS or Windows. The client application is available for Windows and MacOS X only.
1. Open the client application that you downloaded and installed.
2. You will see a number of sections in this application. The 3 sections are Active sessions, Pending sessions, and Completed sessions. To acquire and use the private devices that are associated with your account, you first need to start a session. Click Start a new session.
3. Review the list of private devices associated with your account. Choose one or more devices that you would like to work with in a session. In this example, I select two Android devices and one iOS device.
4. Click Start session with (n) devices on the left of the screen. The devices should appear in few seconds in the Pending sessions section. If you hover over the devices, you can see the state of each session.
5. After the devices are acquired and ready for use, they appear in the Active Sessions section.
You can access the devices with a live view by clicking Remote Control. This gives you access to the physical device. You can change device settings using this option.
The second and the most powerful way to use this feature is to initiate a connection to these devices and make them available locally. Click Connect on the lower right corner of the client application.
You are prompted to enter the sudo password of your local machine if you have an iOS device in your session. The devices should now be connected.
Accessing devices from your local system
There are multiple ways you can access devices from your local system. First you can open a terminal and type adb devices for Android devices or instruments –s devices for iOS devices. These two commands show all of the devices selected in your session.
This level of access provides a new way of using real devices in the cloud. The devices are now available and behave exactly as a real physical device connected to your local machine would. For example, you can access the shell of the device.
You can trigger test runs from command line. For example, the following command runs an espresso test for our sample app from the command line.
Another way to use these devices is through your favorite IDE. In the following example, we use Android Studio to change the app and debug the code. We add a breakpoint at LoginFragment:91 in the sample app code for the login page:
Keep the window for live video streaming of the device open and press debug in Android Studio.
You now have access to a real device in the cloud that you can use for debugging and running your app and tests.
The distinct characteristic of this feature becomes evident here. You are no longer explicitly uploading apps or tests to Device Farm as you would when using public devices. The execution environment shifts from AWS to your local machine. This enables a zero friction way to use devices in the cloud. Not a single line of code needs to change for you to run your app or tests on devices in AWS Device Farm.