For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

TestMu AI Appium Documentation: Run Your First Real Device Test


To run an Appium test on TestMu AI, upload your .apk or .ipa to get an lt:// app ID, add LT:Options capabilities for the device and app, and point your Appium client at the TestMu AI mobile hub. The test runs on a real Android or iOS device, and the video, Appium logs and device logs appear in the App Automation dashboard. Hosts such as manual-api.lambdatest.com and mobile-hub.lambdatest.com, and the LT:Options key, keep their original names and work as shown.

  1. A TestMu AI account. Sign up if you don't have one.
  2. Your Username and Access Key from the TestMu AI Profile page.
  3. An Android app (.apk or .aab) or an iOS app (.ipa). No app yet? Use the sample Android app or iOS app.
  4. The Appium client for your language:
    • Python: Python 3 and the Appium Python Client 2.3.0 or later.
    • Java: a JDK and the Appium Java client (io.appium:java-client) in your Maven or Gradle project. Use the latest release: this sample was tested with java-client 11.0.0.

Using JavaScript, Ruby, PHP, C#, or a framework such as TestNG or pytest? See Appium languages and frameworks.

Step 1: Set Your Credentials​


Export your TestMu AI Username and Access Key as environment variables. The test reads them from LT_USERNAME and LT_ACCESS_KEY, so they never sit in your code.

Verified
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"

Step 2: Upload Your App​


Appium leverages the WebDriver protocol, similar to how Selenium automates web applications. This makes it compatible with popular programming languages for writing test scripts.

To upload from the dashboard instead, or to check supported file types and the 1 GB size limit, see upload apps on the real device cloud.

curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@/path/to/your-app.apk" -F "name=my-app"

In Windows PowerShell, type curl.exe instead of curl.

The response is a JSON object with an app_url of the form lt://APP123456789123456789. Save it as LT_APP_URL for the next step:

export LT_APP_URL="lt://APP123456789123456789"

Step 3: Add Capabilities and Write the Test​


The test sets platformName and an LT:Options block with the device, OS version and app, then connects to the TestMu AI mobile hub at https://mobile-hub.lambdatest.com/wd/hub. Your username, access key and app ID all come from environment variables.

Verified
first_test.py
import os
from appium import webdriver
from appium.options.common import AppiumOptions

lt_options = {
"platformName": "android",
"deviceName": "Galaxy S23",
"platformVersion": "14",
"app": os.environ["LT_APP_URL"],
"isRealMobile": True,
"build": "Appium quickstart",
"name": "First Appium test",
"devicelog": True,
"w3c": True,
}

options = AppiumOptions()
options.set_capability("platformName", "android")
options.set_capability("LT:Options", lt_options)

hub = f"https://{os.environ['LT_USERNAME']}:{os.environ['LT_ACCESS_KEY']}@mobile-hub.lambdatest.com/wd/hub"
driver = webdriver.Remote(command_executor=hub, options=options)

try:
# Add your test steps here
driver.execute_script("lambda-status=passed")
except Exception:
driver.execute_script("lambda-status=failed")
raise
finally:
driver.quit()

Replace the # Add your test steps here comment with your own steps. lambda-status marks the session passed or failed on the dashboard.

To run on iOS, upload an .ipa in Step 2, set platformName to ios in both places, and set deviceName and platformVersion to an iPhone model and iOS version from the Capabilities Generator. In Java, use IOSDriver (io.appium.java_client.ios.IOSDriver) in place of AndroidDriver.

Capabilities Used in This Test​


KeyExamplePurpose
platformNameandroid or iosOS family. Set it at the top level and inside LT:Options.
deviceNameGalaxy S23Device model, spelled exactly as the Capabilities Generator lists it.
platformVersion14OS version of that device.
applt://APP123456789123456789The app_url from Step 2, read from LT_APP_URL.
isRealMobiletrueRuns on a real device. Set it to false to run on an emulator or simulator.
build / nameAppium quickstart / First Appium testBuild and test names on the dashboard.
devicelogtrueCaptures device logs. Off by default.
w3ctrueUses the W3C WebDriver protocol.

Video recording (video) is on by default, and Appium logs are always captured. Set network to true for network logs. Generate a capability set for any device and OS version with the Capabilities Generator, and see Appium desired capabilities on TestMu AI for every supported key.

Run the Test and View Results​


pip install Appium-Python-Client
python3 first_test.py

If python3 is not recognized, use python instead.

Open the App Automation Dashboard. The run appears under the build Appium quickstart with the test First Appium test, marked passed or failed by lambda-status. The session holds the video recording, the Appium logs and the device logs. For a tour of the dashboard, see App Automation Dashboard.

Test a Locally Hosted App With the Tunnel​


A real device in the cloud can't reach localhost, a private staging server or a backend behind your firewall. Route the session through TestMu AI Tunnel so the device can reach them.

  1. Download the Tunnel binary for your operating system:
  2. Extract the file, open a terminal in that folder and start the Tunnel. On Windows, run LT with the same flags.
./LT --user "$LT_USERNAME" --key "$LT_ACCESS_KEY" --tunnelName my-tunnel
  1. With the Tunnel running, add these keys to LT:Options and run the test again:
KeyExamplePurpose
tunneltrueRoutes the session through the Tunnel.
tunnelNamemy-tunnelThe name you passed to --tunnelName. With a single tunnel, tunnel: true alone is enough.

For proxies, several tunnels and other options, see testing locally hosted apps and TestMu AI Tunnel.

Run Appium Tests in CI​


In CI, store your username and access key as secrets, expose them as LT_USERNAME and LT_ACCESS_KEY, upload each new build, and pass its app_url to the test as LT_APP_URL. The test code from Step 3 doesn't change. This GitHub Actions workflow runs the Python test on every push:

.github/workflows/appium.yml
name: Appium tests

on: [push]

jobs:
appium:
runs-on: ubuntu-latest
env:
LT_USERNAME: ${{ secrets.LT_USERNAME }}
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install Appium-Python-Client
- name: Upload the app
run: |
APP_URL=$(curl -s -u "$LT_USERNAME:$LT_ACCESS_KEY" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@path/to/your-app.apk" -F "name=ci-build" | jq -r '.app_url')
echo "LT_APP_URL=$APP_URL" >> "$GITHUB_ENV"
- run: python first_test.py

Replace path/to/your-app.apk with your build output. For Jenkins, GitLab CI, CircleCI, Bitbucket Pipelines and other tools, see CI/CD integrations.

Troubleshooting​


ErrorCauseFix
401 UnauthorizedLT_USERNAME or LT_ACCESS_KEY is unset, stale or missing from the hub URL.Run echo $LT_USERNAME, then copy both values again from the Access Key button on the dashboard. A test started from an IDE may not inherit your terminal's variables.
App not found, or the app capability is rejectedLT_APP_URL is empty, a local file path, or an lt:// ID that no longer exists. Apps unused for 30 days are removed automatically.Upload the app again and set LT_APP_URL to the new app_url.
SessionNotCreatedException or device not availableA capability is missing or misspelled, or the deviceName and platformVersion pair isn't offered.Copy the exact device name and OS version from the Capabilities Generator.
The session connects but no device is allocatedThe test points at the browser hub, hub.lambdatest.com.Use https://mobile-hub.lambdatest.com/wd/hub.
The session ends in the middle of a runNo command arrived within idleTimeout, which defaults to 120 seconds.Raise idleTimeout in LT:Options, for example to 300.
Python rejects the desired_capabilities argumentAppium Python Client 3 and later removed it.Build the driver with AppiumOptions, as in Step 3.
The app can't reach localhost or stagingThe cloud device can't see your private network.Start the Tunnel and add "tunnel": true to LT:Options.

For more errors and fixes, see troubleshooting Appium tests on TestMu AI.

FAQ​


How do I run Appium tests on iOS with TestMu AI?​

Upload your .ipa in Step 2. In Step 3, set platformName to ios, and set deviceName and platformVersion to an iPhone model and iOS version from the Capabilities Generator. In Java, use IOSDriver in place of AndroidDriver. The rest of the test stays the same.

Can I run Appium tests on emulators and simulators?​

Yes. Upload the app to https://manual-api.lambdatest.com/app/upload/virtualDevice and set isRealMobile to false. For an iOS simulator, upload a .zip of the app instead of an .ipa. See app upload with the REST API.

Do I need a local Appium server?​

No. Your test sends its commands to the TestMu AI mobile hub at mobile-hub.lambdatest.com, which runs the session on the cloud device. You only install the Appium client for your language.

Where do I find the capabilities for a specific device?​

Use the Capabilities Generator to build a capability set for any device and OS version. Appium desired capabilities on TestMu AI lists every supported key.

How do I run tests on several devices at once?​

Start one Appium session per device. Each device runs one automation session at a time, and your plan's concurrent session limit sets how many run in parallel. Tests above that limit wait in a queue. See queuing Appium tests.


To test your app on real Android and iOS devices in the cloud, see the TestMu AI Real Device Cloud.

Help and Support

Related Articles