Prerequisites
Before you can run tests on Android devices, you’ll need to set up Appium:-
Install Appium Server and dependencies:
-
Verify your Appium installation:
This command will check your system and highlight any issues that need to be fixed.
-
Start the Appium server:
You’ll need to keep this server running in a separate terminal window while executing your tests.
Setting Up an Android Device
Testpilot discovers Android devices through the Android Debug Bridge (adb). You have several options for creating test devices:Option 1: Android Studio Emulator (Recommended)
- Download and install Android Studio
- Launch Android Studio and open the Device Manager
- Click on “Create Device” and select “Pixel 7” (recommended for optimal compatibility)
- Choose a system image (Android 12 or newer is recommended)
- Complete the setup and start the emulator
Option 2: Physical Device
-
Enable Developer Options on your Android device:
- Go to Settings > About Phone
- Tap “Build Number” 7 times to enable Developer Options
- Enable USB Debugging in Developer Options
- Connect your device to your computer with a USB cable
- Accept any authorization prompts on your device
Option 3: Connecting with Emulator.wtf
emulator.wtf lets you quickly spin up remote Android emulators, connect over ADB, and run your Android Unit and Testpilot tests on the remote device. You can connect Testpilot to youremulator.wtf
devices using the following steps:
- Create an
emulator.wtf
account and API token. - Set your API token to the following env var:
EW_API_TOKEN
- Follow the documentation to install the
emulator.wtf
CLI - Run the following command to create an
emulator.wtf
device and connect it to your localadb
:ew-cli start-session --device model=Pixel7,version=34,gpu=auto
- You’re device is now ready to run Appium tests!
Creating an Android Test
Create a test file (e.g.,android-test.pilot.yaml
) with the platform_config specifying your
Android app package:
Running Android Tests
To run a test on an Android device, use the following command:Test Platform Configuration
Theplatform_config
section lets you define the android app that you want to run your tests on.
You can specify an app and URL for both browser based and native application tests
- Use
url
for browser-based tests on Android Chrome - Use
android_pkg
for native Android app tests