How to Run Appium Tests Against the Android Emulator in a Cloud VM
Updated November 25, 2026 .md
Short answer: On a large Sandboxer sandbox, boot the Android emulator headless with KVM, install Appium 2 with the UiAutomator2 driver pinned to 4.2.9, and point a Python Appium client at 127.0.0.1:4723. In our run, setup took 72 seconds, the emulator booted in 26, and a Settings test passed in 19.
Part of Docker, Kubernetes and Nested VMs in a Cloud Sandbox.
Where Sandboxer fits: each sandbox is an Ubuntu 24.04 microVM with its own kernel and /dev/kvm, so the emulator runs as an accelerated nested VM, and Appium, adb and your test client sit next to it in the same machine (Machines). Plans start at $20/mo (pricing).
The emulator itself (SDK install, -accel on, adb, the streamed desktop, stop and resume) is covered in Run the Android emulator in a cloud VM. This page starts where that one stops: Appium on top, one real UI test, and the version trap you hit with Appium 2 today.
What we measured#
One large sandbox (8 vCPU, 16 GB RAM) in us-east, 2026-11-25, running the copy-paste block at the end of this page. We used large because the emulator's RAM comes out of the sandbox's, as in the emulator guide.
| Step | Time |
|---|---|
Java, Android command-line tools, emulator, Android 15 google_apis x86_64 image, AVD |
56 s |
| Appium 2.19.0, UiAutomator2 driver 4.2.9, Appium Python client 6.1.8 | 16 s |
Emulator cold boot to sys.boot_completed=1 |
26 s (emulator log: Boot completed in 25170 ms) |
| Test run, first session on a fresh device | 19 s (session start 12.2 s) |
| Test run, later sessions on the same device | 8 s (session start 4.5–4.9 s, in an earlier sandbox the same day) |
Whole block, sbx new to sbx delete |
2 min 2 s |
The first session is slower because Appium installs its UiAutomator2 server APKs on the device. Later sessions reuse them.
The version trap: Appium 2 and the newest UiAutomator2 driver#
On 2026-11-25, npm view reported Appium latest as 4.0.1 and the UiAutomator2 driver latest as 10.4.0. With Appium 2 installed, appium driver install uiautomator2 failed:
Error: ✖ 'uiautomator2' cannot be installed because the server version it requires (^4.0.0-beta.8) does not meet the currently installed one (2.19.0). Please install a compatible server version first.The driver's peer dependency tells you which line still works. Driver 4.x is the last one that accepts Appium 2:
npm view appium-uiautomator2-driver@4 peerDependencies.appium | tail -1
npm view appium-uiautomator2-driver@5 peerDependencies.appium | tail -1appium-uiautomator2-driver@4.2.9 '^2.4.1 || ^3.0.0-beta.0'
appium-uiautomator2-driver@5.0.7 '^3.0.0-rc.2'So on Appium 2, install uiautomator2@4.2.9. If you can move to a newer Appium, follow the Appium docs and install the driver without a version.
Three other things that failed first#
npm install -gasuser. Node's global prefix in the sandbox is/usr, so a global install withoutsudodoesn't putappiumon thePATH(appium: command not found).npm config set prefix ~/.localfixes it, since~/.local/binis already onuser'sPATH.adb: device offlineon the first session. Our first test, started right after boot, failed during session setup withError executing adbExec … adb: device offline.adb devicesshoweddevicea moment later, and the next run passed. In the clean run below it didn't happen.- No wait after a tap. Looking up the next screen's
Internetitem right afterclick()raisedNoSuchElementException.driver.implicitly_wait(10)fixed it.
The test#
A Python Appium client opens Settings, finds Network & internet by its text through a UiAutomator selector, taps it, waits for the next screen, reads its labels and saves a screenshot:
driver = webdriver.Remote("http://127.0.0.1:4723", options=opts) # appPackage com.android.settings
driver.implicitly_wait(10)
item = driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("Network & internet")')
item.click()
driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("Internet")')
texts = [e.text for e in driver.find_elements(AppiumBy.CLASS_NAME, "android.widget.TextView")]
driver.save_screenshot("network.png")Appium listens on 127.0.0.1 only, so nothing outside the sandbox can reach it. The full file is in the copy-paste block.
The saved screenshot was a 148,293-byte PNG, 1080 x 2400. It shows the Network & internet screen: Internet (AndroidWifi), SIMs, Airplane mode switched off, Hotspot & tethering, Data Saver, VPN and Private DNS.
Copy-paste: run an Appium test on a fresh emulator#
Install the CLI with curl -fsSL https://sandboxer.com/install | sh and sign in with sbx login. Then paste this. It writes the test file, creates a large sandbox with none of your secrets, installs the Android SDK, Appium 2 and the client, boots the emulator, runs the test, copies the screenshot back and deletes the sandbox. It uses jq on your machine.
cat > test_settings.py <<'EOF'
import time
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
opts = UiAutomator2Options()
opts.platform_name = "Android"
opts.device_name = "emulator-5554"
opts.app_package = "com.android.settings"
opts.app_activity = ".Settings"
t0 = time.time()
driver = webdriver.Remote("http://127.0.0.1:4723", options=opts)
print(f"session started in {time.time() - t0:.1f}s")
driver.implicitly_wait(10)
try:
item = driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("Network & internet")')
print("found:", item.text)
item.click()
driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("Internet")')
texts = [e.text for e in driver.find_elements(AppiumBy.CLASS_NAME, "android.widget.TextView")]
print("next screen shows:", texts[:6])
print("current activity:", driver.current_activity)
driver.save_screenshot("network.png")
finally:
driver.quit()
print(f"test finished in {time.time() - t0:.1f}s")
EOF
id=$(sbx new --name appium-test --type large --no-env --ttl 3600 --json | jq -r 'select(.event=="ready") | .id')
sbx scp test_settings.py "$id":/home/user/test_settings.py
sbx exec "$id" --timeout 600 'set -e; S=$(date +%s)
sudo apt-get update -qq && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq openjdk-17-jre-headless >/dev/null 2>&1
mkdir -p ~/android/cmdline-tools && cd /tmp
curl -fsSLo tools.zip https://dl.google.com/android/repository/commandlinetools-linux-16111833_latest.zip
unzip -q tools.zip && mv cmdline-tools ~/android/cmdline-tools/latest
cat >> ~/.profile <<"EOF"
export ANDROID_HOME=$HOME/android
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH
EOF
. ~/.profile
yes | sdkmanager --licenses >/dev/null 2>&1 || true
sdkmanager "platform-tools" "emulator" "system-images;android-35;google_apis;x86_64" >/dev/null 2>&1
echo no | avdmanager create avd -n pixel -k "system-images;android-35;google_apis;x86_64" -d pixel_7 >/dev/null
echo "android sdk + image: $(( $(date +%s) - S ))s"; S=$(date +%s)
npm config set prefix ~/.local
npm install -g --silent appium@2 >/dev/null 2>&1
appium driver install uiautomator2@4.2.9 >/dev/null 2>&1
python3 -m venv ~/venv && ~/venv/bin/pip install -q Appium-Python-Client
echo "appium $(appium --version) + uiautomator2 $(appium driver list --installed 2>&1 | grep -o "uiautomator2@[0-9.]*" | cut -d@ -f2) + python client: $(( $(date +%s) - S ))s"'
sbx exec "$id" "adb start-server" >/dev/null 2>&1
sbx exec "$id" --detach "emulator -avd pixel -no-window -no-audio -no-boot-anim -accel on -gpu swiftshader_indirect > ~/emulator.log 2>&1" >/dev/null
sbx exec "$id" --detach "appium --address 127.0.0.1 --port 4723 > ~/appium.log 2>&1" >/dev/null
sbx exec "$id" --timeout 300 'S=$(date +%s); adb wait-for-device
until [ "$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d "\r")" = 1 ]; do sleep 2; done
echo "emulator boot: $(( $(date +%s) - S ))s ($(grep -o "Boot completed in [0-9]* ms" ~/emulator.log))"
until curl -s 127.0.0.1:4723/status >/dev/null; do sleep 1; done
S=$(date +%s); ~/venv/bin/python test_settings.py 2>&1 | grep -v "^ "
echo "test run: $(( $(date +%s) - S ))s"; file network.png'
sbx scp "$id":/home/user/network.png . && ls -l network.png
sbx delete "$id" --yes
sbx info "$id"Our run on 2026-11-25 (trimmed with …):
android sdk + image: 56s
appium 2.19.0 + uiautomator2 + python client: 16s
emulator boot: 26s (Boot completed in 25170 ms)
session started in 12.2s
found: Network & internet
next screen shows: ['Internet', 'AndroidWifi', 'SIMs', 'CARD 1', 'Airplane mode', 'Hotspot & tethering']
current activity: .SubSettings
test finished in 18.7s
test run: 19s
network.png: PNG image data, 1080 x 2400, 8-bit/color RGBA, non-interlaced
-rw-r--r-- 1 … 148293 Nov 25 11:11 network.png
{"ok":true,"type":"deletion.operation","operation":{…,"status":"completed","targetId":"sb_a332jllodl"}}
{"event":"error","error":"Sandbox not found","code":"not_found","status":404,…}The driver version after uiautomator2 came out empty because appium driver list colors its output, so the grep didn't match. The install itself worked: in an earlier sandbox the same day, appium driver list --installed showed uiautomator2@4.2.9 [installed (npm)], and the test above ran through it. The last line confirms the sandbox is gone.
To skip the 72 seconds of setup on every run, save a prepared sandbox as a named snapshot and start each test sandbox from it (snapshots). Quit the emulator with adb emu kill before you save or stop, as the emulator guide explains.
FAQ#
Which UiAutomator2 driver version works with Appium 2?#
Driver 4.x, whose peer range is ^2.4.1 || ^3.0.0-beta.0; we used 4.2.9. Drivers 5.0.7, 6.9.3 and 7.6.2 need Appium 3, and on 2026-11-25 the newest, 10.4.0, needed Appium 4.
Does Appium need a GPU or a display in the sandbox?#
No. The emulator ran with -no-window and -gpu swiftshader_indirect, which renders in software. Sandboxer has no GPUs. Appium drives the device through adb and the UiAutomator2 server.
Can I run the Appium server outside the sandbox?#
Our run kept Appium on 127.0.0.1 inside the sandbox, next to adb and the emulator, and the test ran there too. We didn't test a remote Appium client against a hosted port.
Can I use JavaScript instead of Python?#
Appium has clients for several languages, including WebdriverIO for JavaScript (Appium docs). We ran the Python client only, so the timings above are for Python.
Why does the first test take longer than the rest?#
On a fresh device, Appium installs the UiAutomator2 server APKs before the session starts. Our first session started in 12.2 s; later sessions on the same device started in under 5 s.
Related#
More guides
For running AI-written code we rank Sandboxer, Freestyle and E2B first: each gives code its own VM with an API or SDK and can pause with memory. Pick Daytona for Windows or GPUs, Modal or Northflank for GPUs at scale, E2B or Northflank to run in your own cloud, and Vercel Sandbox if your app lives on Vercel.
For coding agents we rank Sandboxer first: a full Ubuntu VM with Claude Code and Codex preinstalled, Docker, and stop-and-resume that keeps the agent's session in memory. Freestyle and Amp Orbs also keep memory across pauses. Pick E2B for prebuilt agent templates on open source, Docker Sandboxes for free local runs, and Codespaces if you live in GitHub.
The best Daytona alternatives depend on why you're switching. For a full Linux microVM on every sandbox with memory-saving stop and Docker, we rank Sandboxer first. E2B suits open source and self-hosting, Modal massive short-job fleets, Northflank bring-your-own-cloud with GPUs, and Vercel Sandbox apps on Vercel.
If you're leaving E2B for longer sessions or a fuller machine, we rank Sandboxer first, then Freestyle: both give each sandbox a full Linux VM that keeps memory across pauses, with Docker and no short session cap. Pick Daytona for Windows or GPUs, Northflank for bring-your-own-cloud, and stay on E2B if you need open source.