Menu
AWS Device Farm
Developer Guide (API Version 2015-06-23)

Use a Remote Debugging Session in AWS Device Farm

Prerequisites

View and Interact with Devices by Remote Control

Once the device you requested for a remote debugging session becomes available, choose Remote Control to open the device window to interact with the device (but not debug it). You can interact remotely with the device as you would the actual physical device using your mouse for touch and the device's on-screen keyboard or the physical keyboard on your laptop.

The session has a default timeout value of of 60 minutes. You can change this value. For more information, see Set the Execution Timeout for Test Runs in AWS Device Farm.


                Device Farm - Connect button

The device window allows you to view and control the device via streaming video.

Note

The device won't be visible in Android Studio or Xcode until you connect to it.


                Device Farm - Device window

Connect to Remote Devices

You can connect to your remote devices and debug them locally, as if they were connected directly to your computer. To connect to remote devices, choose the Connect button. This creates an ssh tunnel to the EC2 instance that hosts your devices, and you can now use them locally using your preferred debugging tools. You will lose any local device connections that you already had.

Now the devices are visible to your IDE (for example, Android Studio or Xcode) and other tools (such as ADB for Android and Instruments for iOS.

Note

The first time you connect to the ssh tunnel on Macintosh, you'll need to enter the local machine's Macintosh root password.


                Device Farm - Connect button

If you encounter a "Connect to remote devices failed" error, you can troubleshoot the error as follows:

  1. In the Advanced menu, choose View Logs.

    
                        Device Farm - View Logs menu item
  2. In the logs, look for the following line, where host_ip is the host IP address:

    Copy
    [date time] [info] Creating ssh tunnel to host address: host_ip

    Copy the host IP address.

  3. Open a terminal window and run the following command, where host_ip is the host IP address you copied from the logs:

    Copy
    ssh –v –N -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null –L 5037:localhost:5038 –i “~/.aws/devicefarm/prikey.pem” device-farm@host_ip
  4. Check the command output to see why the connection attempt failed.

Switching Between Remote and Local Devices

To disconnect from a remote device, choose the Disconnect button.

When you disconnect from your remote devices, you will no longer see them in your debugger. You will only see your local devices.

To reconnect to your remote devices, choose Connect.


                Device Farm - Connect button

Debugging Your App Remotely with Android Studio

Once you've connected to a remote device in the Device Farm app, you can begin to debug your app with Android Studio as follows:

  1. Launch Android Studio.

  2. Choose the Run button to run your app. A dialog box will appear that lists your connected devices. Your remote Device Farm devices will appear as if they were local devices physically connected to your computer.

  3. Connect to a device and debug your app.


                Device Farm - Device window

Debugging Your App Remotely with Xcode

Once you've connected to a remote device in the Device Farm app, you can begin to debug your app with Xcode as follows:

  1. Launch Xcode. Your remote Device Farm devices will appear in device selection menus as if they were local devices physically connected to your computer..

  2. Connect to a device and debug your app.

Note

Following are some guidelines for remote debugging by using Xcode:

  1. When using the remote iOS device for the first time, you may see the warning "Processing symbol files" in Xcode. This will take some time and prevent you from running or debugging your app on the remote device. Wait until it is done before you use your remote device.

  2. When you connect to a remote device, you might not see the device in Xcode if Xcode was open before you connected to the first remote device. If this happens, restart Xcode, and you should be able to see the device in Xcode.

  3. If you get a failure interacting with the device using the libimobiledevice library, open the video stream for the device and accept the trust pop-up if one appears. You should then be able to list the device using the libimobiledevice library.

  4. In order to launch an app on the iOS device, you can either use the Xcode-managed provisioning profile or use your own provisioning profile. If you want to use your own provisioning profile, you should add the udid of the device to your provisioning profile. You can get the udid of the device by hovering over the device name in the Active Sessions list in the Device Farm client app. After adding the udid of the device to your provisioning profile, update your Xcode to use the latest provisioning profile.


                Device Farm - Device window

                Device Farm - Device window

Using Test Automation

Once you've connected to your remote devices, they should appear as if they were connected locally. You can run your test in concurrent fashion against multiple devices (a single iOS device or multiple Android devices) using your preferred test automation framework, such as Calabash, Appium, or Spoon.

To verify that your device is connected, use a command such as adb or instrument.

Verifying Device Connection Using ADB for Android

To verify the connection, type adb devices at the command prompt. Once you can list the devices locally, you should be able to run test automation as if the the devices are connected locally.


                    Device Farm - Device window

Verifying Device Connection Using instruments for iOS

To verify the connection, type instruments -s at the command prompt. Once you can list the devices locally, you should be able to run test automation as if the the devices are connected locally.


                    Device Farm - iOS Device window

Using Spoon Test Automation to Debug Multiple Android Devices

Here is a screenshot that shows test automation running on multiple devices on Spoon.


                    Device Farm - Android Device window

Debugging Web Apps

In addition to native apps, you can also debug web apps on remote devices.

Debugging Web Apps on Android

Once you've connected to a remote Android device in the Device Farm app, you can begin to debug your web app as follows:

  1. Open the Chrome browser on your computer and navigate to chrome://inspect#devices to see if you're connected to the remote device.

    
                            Device Farm - Device window
  2. In the Device Farm app device window, perform the following steps on your remote device:

    1. Choose Remote Control to get a device window.

    2. Open the Chrome browser on the remote device.

    3. Open the UI for your web app, for example, www.google.com.

  3. In the Chrome browser on your computer, you should now see that Chrome is also running on the remote device:

    
                            Device Farm - Chrome inspect
  4. In the chrome://inspect#devices window on your computer, choose Inspect to open Chrome developer tools.

    
                            Device Farm - Chrome inspect

    Here's what the tools look like:

    
                            Device Farm - Chrome inspect - device window
  5. Start debugging your app.

Debugging Web Apps on iOS

Once you've connected to a remote iOS device in the Device Farm app, you can begin to debug your web app as follows:

  1. Open the Safari browser on your computer.

  2. In the Develop menu, choose the entry that corresponds to your remote device.

    
                            Device Farm - Safari Web Inspector
  3. In the Device Farm app device window, perform the following steps on your remote device:

    1. Choose Remote Control to get a device window.

    2. Open the Safari browser.

    3. Open the UI for your web app, for example, www.google.com.

  4. In the Safari window on your computer, in the Develop menu, open the UI for your web app by choosing the entry corresponding to the remote device.

    
                            Device Farm - Safari Web Inspector

    This will open a Web Inspector showing the source code for the web page on the remote device.

    
                            Device Farm - Chrome inspect - device window
  5. Start debugging your app.