Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 3.68 KB

Device_Mode.md

File metadata and controls

68 lines (47 loc) · 3.68 KB

Device Mode

Overview

Device mode allows Appium-based tests to be run on either local or remote Android and iOS devices using a service such as BitBar or BrowserStack. Device mode is generally invoked by using the --app option, which is the path to an APK or IPA application file. For some device farms, an id or URI can be used to refer to a previously uploaded app.

Environment variables

To run tests on BitBar or BrowserStack you will need an account and set one of the following pairs of environment variables:

  • BROWSER_STACK_USERNAME/BROWSER_STACK_ACCESS_KEY
  • BITBAR_USERNAME/BITBAR_ACCESS_KEY

Device farms tend to offer a tunnelling facility, allowing HTTP requests sent by the device to be received by the Maze Runner server. Both BitBar and BrowserStack use a local binary to support this mechanism, and one of the following environment variables should be set to its location in order that Maze Runner can automatically start the tunnel.

MAZE_BS_LOCAL/MAZE_SB_LOCAL

Example usage with BrowserStack

Run the bugsnag-android "smoke tests" the fixture-debug.apk app on BrowserStack using an Android 9 device, stopping immediately if any scenario fails.

bundle exec maze-runner features/smoke_tests    \
                        --app=fixture-debug.apk \
                        --farm=bs               \
                        --device=ANDROID_9_0    \
                        --fail-fast

Note the use of ANDROID_9_0, which is mapping to an entry in a hash that's dynamically generated by BrowserStack devices. There are many other available options, as shown by comments in that source file.

Example usage with BitBar

Running tests on BitBar work in a very similar way:

bundle exec maze-runner features/smoke_tests    \
                        --app=fixture-debug.apk \
                        --farm=bb               \
                        --device=ANDROID_9      \
                        --fail-fast

For BitBar, the --device option maps directly to the name of either a device, or a device group configured in the BitBar dashboard. Multiple device groups can also be listed, separated by a pipe. Maze Runner will select an available device from them at random. E.g. --device=ANDROID_10|ANDROID_11.

Appium client modes

By default, Maze Runner will use the latest version of appium_lib, the Ruby Appium library. For versions onwards, the library enforces the use of W3C mode, which in turn means that Appium server v1.15 or later must be used. If an earlier version is needed for any reason, this case be achieved by setting the USE_LEGACY_DRIVER environment variable when both bundle installing the Gem and when executing it. appium_lib v11 will then be installed and JWP protocol employed.

rm Gemfile.lock
USE_LEGACY_DRIVER=1 bundle update
USE_LEGACY_DRIVER=1 bundle exec maze-runner features/smoke_tests    \
                                            --app=fixture-debug.apk \
                                            --farm=bs               \
                                            --device=ANDROID_9_0

Note that the Gemfile.lock must also be removed when taking this approach.

Test fixture config files

Test fixture apps need to know the netword address of the MAze Runner server in order to configure Bugsnag properly. Rather than having to hard code the address in test fixture code, Maze Runner had the concept of a test fixture configuration file. This is a JSON file written to disk locally under maze_working/ and pushed onto the device using Appium. A test fixture can then read this file to find the address. Example file:

{
  "maze_address": "bs-local.com:9339"
}