Mobilewright is a framework for mobile automation and testing. Control iOS and Android devices, simulators, and emulators from tests, scripts, coding agents, and MCP clients, with a developer experience inspired by Playwright.
Get Started · API Examples · Documentation · API Reference · Roadmap · Mobile Next Cloud
Choose the path that fits your workflow:
| Best for | Install / start | |
|---|---|---|
| Mobilewright Test | End-to-end mobile testing | npm init mobilewright@latest |
| Mobilewright CLI | Coding agents and terminal automation | npm install -g @mobilewright/cli@latest |
| Mobilewright MCP | AI agents using structured tools | npx -y @mobilewright/mcp@latest |
| Mobilewright Library | Mobile automation scripts | npm install mobilewright |
All four workflows require Node.js 22.12 or newer. For local automation, have a booted simulator or emulator, or a connected device ready before you start:
- iOS: macOS with Xcode and the Command Line Tools. Boot an iOS simulator, or connect and trust a real iPhone.
- Android: a JDK and the Android SDK, with
ANDROID_HOMEset andadbon yourPATH. Start an emulator, or connect a device with USB debugging enabled and authorized. - Your app: install a build on the device and note its bundle ID (iOS) or package name (Android). The examples use
com.example.myapp; replace it with your app's ID and adapt the labels and expected text to your app.
Check your local environment and available devices:
npx mobilewright doctor
npx mobilewright devicesMobilewright includes mobilecli for local device control. The doctor command reports missing dependencies and how to fix them.
For a real iPhone, install the device agent using a development provisioning profile that includes your device and a matching signing certificate with its private key in your Mac's keychain:
npx mobilewright install --device <device-id> --provisioning-profile /path/to/profile.mobileprovisionReplace <device-id> with the ID from devices and the profile path with your own. See mobilecli setup for signing requirements.
See Installation, Windows setup, Android in Docker, and Troubleshooting for platform-specific instructions. Tests and library scripts can also use cloud device providers; MCP supports Mobile Next Cloud without a local device toolchain.
Write repeatable end-to-end tests with @mobilewright/test, which extends Playwright Test with mobile device and screen fixtures, auto-waiting locators, retrying assertions, and test reports.
Scaffold a project:
npm init mobilewright@latestOr add Mobilewright to an existing Node.js project:
npm install --save-dev mobilewright @mobilewright/test
npx mobilewright initEdit the generated mobilewright.config.ts (or mobilewright.config.js if you chose JavaScript):
import { defineConfig } from 'mobilewright';
export default defineConfig({
platform: 'ios',
bundleId: 'com.example.myapp',
deviceName: /iPhone/,
timeout: 30_000,
});For Android, set platform: 'android' and change or remove deviceName. You can also select a specific device with deviceId. The app must already be installed, or you can add installApps with the path to a compatible build, such as an Android .apk or a real-device iOS .ipa.
Replace the generated example test with this sign-in flow. Use your app's field labels, a test account, and the text shown after a successful sign-in:
import { test, expect } from '@mobilewright/test';
test('can sign in', async ({ screen }) => {
await screen.getByLabel('Email').fill('user@example.com');
await screen.getByLabel('Password').fill('password123');
await screen.getByRole('button', { name: 'Sign In' }).tap();
await expect(screen.getByText('Welcome back')).toBeVisible();
});The fixtures connect to the configured device, restart the configured app before each test by default, and close the connection when the worker finishes. A screenshot is attached to the report when a test fails.
npx mobilewright testGenerate and open an HTML report:
npx mobilewright test --reporter html
npx mobilewright show-reportWriting tests · Running tests · Configuration · Fixtures · CI setup
mobilewright-cli lets coding agents such as Claude Code, Codex, and Cursor control mobile devices through shell commands. It returns compact accessibility snapshots with element references, and prints the corresponding Mobilewright code after actions so an explored flow can become a test.
npm install -g @mobilewright/cli@latestOptionally install the bundled agent skill in your project. For Claude Code:
mobilewright-cli installFor agents that discover skills in .agents/skills/:
mobilewright-cli install --skills agentsList devices, launch your installed app, and read the screen:
mobilewright-cli devices
mobilewright-cli --device <device-id> launch com.example.myapp
mobilewright-cli snapshotReplace <device-id> with an ID from devices. The CLI remembers it for later commands; when exactly one device is online, you can omit --device.
A sign-in screen might look like this:
- textfield "Email" [ref=e7]
- textfield "Password" [ref=e8]
- button "Sign In" [ref=e9]
Use the references from your own snapshot to interact:
mobilewright-cli fill e7 "user@example.com"
mobilewright-cli fill e8 "password123"
mobilewright-cli tap e9
mobilewright-cli expect visible --text "Welcome back"
mobilewright-cli screenshot -o welcome.pngReferences can change as the screen changes. Read the fresh snapshot after each action and use its current refs in the next command; e7, e8, and e9 above are illustrative. To install a build first, use mobilewright-cli app-install ./builds/myapp.apk with the appropriate file for your device.
Use mobilewright-cli to explore the sign-in flow in com.example.myapp
on my connected device. Ask me for test credentials, verify that the
welcome screen appears, and save a screenshot. Then write the flow as
a Mobilewright test.
Full CLI documentation covers commands, device selection, named sessions, JSON output, and skill installation.
Mobilewright MCP gives AI agents device control through the Model Context Protocol. The @mobilewright/mcp package provides the Mobile MCP server, with tools for device discovery, app installation, accessibility inspection, gestures, screenshots, and more.
Add this to a client that uses mcpServers configuration, such as Claude Desktop or Cursor:
{
"mcpServers": {
"mobilewright": {
"command": "npx",
"args": ["-y", "@mobilewright/mcp@latest"]
}
}
}Your MCP client starts the server using this command. Reconnect or restart the client after saving the configuration. Clients with a different configuration format can register the same command and arguments; see the client setup guide.
First ask your agent:
List the available mobile devices
Once your device appears, try an app workflow:
Open com.example.myapp on my connected device. Inspect the sign-in screen,
ask me for test credentials, and sign in. Verify that the welcome screen
appears and save a screenshot.
The agent reads the device's accessibility elements to understand the screen and act on it. Screenshots and coordinate actions are also available when needed. You can then ask it to turn the flow into a repeatable Mobilewright test.
MCP tools and setup · From an agent session to a CI test
Use mobilewright directly in JavaScript or TypeScript scripts to automate apps, capture screenshots, and control devices.
npm install mobilewrightSave this as sign-in.mjs. It connects to an available iOS device, launches your installed app, signs in, and saves a screenshot:
import { ios, expect } from 'mobilewright';
const device = await ios.launch({ bundleId: 'com.example.myapp' });
try {
const screen = device.screen;
await screen.getByLabel('Email').fill('user@example.com');
await screen.getByLabel('Password').fill('password123');
await screen.getByRole('button', { name: 'Sign In' }).tap();
await expect(screen.getByText('Welcome back')).toBeVisible();
await screen.screenshot({ path: 'welcome.png' });
} finally {
await device.close();
}Replace the app ID, credentials, and locators with your app's values, then run:
node sign-in.mjsFor Android, import android and use android.launch(...). Pass deviceId or a deviceName regular expression to choose a device, or installApps to install a build before launching. Library scripts pass these options directly to launch().
Locators · Actions · Assertions · Screenshots
- iOS and Android — automate native and hybrid apps on simulators, emulators, and real devices.
- Playwright-style API —
screen.getByRole('button').tap(), chainable locators, andexpectassertions. - Auto-waiting — locator actions wait for elements to be actionable; assertions retry until satisfied or timed out.
- Agent workflows — use the CLI for shell-based agents or MCP for agents that call structured tools.
- WebViews — access embedded web content with a Playwright-compatible Page and Locator API.
- Developer tools — explore screens with Inspector, record tests with Codegen, and inspect results in HTML reports.
- Remote devices — connect to mobilecli on another machine or use a supported cloud provider.
These are independent examples to use inside a test or library script. In tests, use the screen and device fixtures and import expect from @mobilewright/test. In scripts, use device.screen and import expect from mobilewright, as in the library quick start.
Find native elements by what users see or by an accessibility identifier:
screen.getByText('Welcome', { exact: true }); // exact text
screen.getByText(/welcome/i); // case-insensitive RegExp match
screen.getByText('welcome', { exact: false }); // substring match
screen.getByLabel('Email'); // accessibility label
screen.getByTestId('login-button'); // accessibility identifier
screen.getByRole('button', { name: 'Sign In' }); // semantic role and name
screen.getByRole('button', { name: /sign in/i }); // role with a RegExp name
screen.getByPlaceholder('Search...'); // placeholder textLocators are lazy: creating one does not query the device. Chain and filter them to narrow a match:
const cartItem = screen.getByRole('listitem').filter({ hasText: 'Milk' });
await cartItem.getByRole('button', { name: 'Remove' }).tap();
const items = screen.getByRole('listitem');
const count = await items.count(); // current number of matches
await items.nth(1).tap(); // second item, zero-basedLocator actions wait for elements to be visible, enabled, and stable before interacting:
await screen.getByLabel('Email').fill('user@example.com');
await screen.getByLabel('Search').clear();
await screen.getByRole('button', { name: 'Continue' }).tap();
await screen.getByRole('switch', { name: 'Notifications' }).check();
await screen.getByTestId('photo').doubleTap();
await screen.getByText('Message').longPress({ duration: 1000 });
await screen.getByTestId('carousel').swipe({ direction: 'left' });
await screen.getByText('Terms of service').scrollIntoViewIfNeeded();Assertions retry until the condition is met or the timeout expires:
await expect(screen.getByText(/welcome/i)).toBeVisible();
await expect(screen.getByText('Loading')).not.toBeVisible();
await expect(screen.getByRole('button', { name: 'Continue' })).toBeEnabled();
await expect(screen.getByRole('switch', { name: 'Notifications' })).toBeChecked();
await expect(screen.getByTestId('status')).toHaveText(/ready/i);
await expect(screen.getByLabel('Email')).toHaveValue('user@example.com');
await expect(screen.getByRole('listitem')).toHaveCount(3);Control the app, open deep links, and capture the screen through the connected device:
await device.terminateApp('com.example.myapp');
await device.launchApp('com.example.myapp');
await device.openUrl('myapp://settings');
await device.setOrientation('landscape');
await screen.screenshot({ path: 'screenshots/settings.png' });
await screen.screenshot({ path: 'screenshots/settings.jpg', format: 'jpeg', quality: 80 });
const image = await screen.getByTestId('profile-card').screenshot(); // cropped PNG Buffer
const size = await device.screenSize(); // { width, height, scale }In standalone scripts, call device.close() in a finally block, as shown in the library example. Test fixtures manage the connection for you. Device capabilities, such as orientation and deep links, depend on the platform and driver.
For a hybrid app, navigate to a screen containing an embedded WebView in a debug/development build, then use its Playwright-compatible Page and Locator APIs:
const page = await screen.getByWebView().page();
await page.getByLabel('Email').fill('user@example.com');
await page.getByRole('button', { name: 'Sign In' }).click();
await expect(page).toHaveURL(/dashboard/);
await expect(page.getByRole('heading', { name: 'Welcome' })).toBeVisible();Use screen.getByWebView({ testId: 'checkout' }) to select a particular WebView. See the WebViews guide for platform requirements, frames, navigation, and real touch input.
Tests and library scripts share the same device, screen, locator, and assertion APIs. Start with these guides:
| API / topic | Documentation |
|---|---|
screen.getByRole(), getByLabel(), getByText(), getByTestId() |
Locators and platform mappings |
locator.tap(), fill(), swipe(), and device actions |
Actions |
expect(locator) and retrying assertions |
Assertions |
| Actionability and explicit waits | Auto-waiting |
screen.screenshot() and screenshot files |
Screenshots |
screen.getByWebView().page() and web locators |
WebViews |
| Device URLs, dialogs, and location | Deep links, Dialogs, Geolocation |
defineConfig() and test options |
Configuration |
test, device, screen, and test.use() |
Test fixtures |
| Multiple devices, retries, and CI distribution | Projects, Retries, Sharding |
The mobilewright executable ships with the library and provides test running, setup, and debugging tools. The separate mobilewright-cli executable provides interactive commands for coding agents.
| Command | Purpose |
|---|---|
npx mobilewright init |
Create a configuration and example test; skip files that already exist |
npx mobilewright doctor |
Check the local environment and report missing dependencies |
npx mobilewright devices |
List devices, simulators, and emulators |
npx mobilewright install |
Install the mobilecli device agent |
npx mobilewright test |
Run tests using your Mobilewright configuration |
npx mobilewright show-report |
Open an HTML test report |
npx mobilewright merge-reports ./blob-reports |
Combine reports from sharded runs |
npx mobilewright screenshot -o home.png |
Save a device screenshot |
npx mobilewright inspect |
Explore a device and find locators |
npx mobilewright codegen |
Record device interactions as test code |
See the command reference for options, test filtering, reporters, and parallel execution.
npx mobilewright inspectThe Inspector opens in your browser with a live device screenshot and element locators. Choose a device, inspect its elements, and copy locators for your tests or scripts.
npx mobilewright codegenInteract with your device from the browser while Codegen records taps, gestures, and assertions as test code.
| Package | Description |
|---|---|
mobilewright |
Library with ios and android launchers, expect, configuration, and the mobilewright test and utility commands |
@mobilewright/test |
Playwright Test integration with mobile fixtures and assertions |
@mobilewright/cli |
The mobilewright-cli executable and bundled skill for coding agents |
@mobilewright/mcp |
MCP server entry point powered by Mobile MCP |
@mobilewright/core |
Device, Screen, Locator, and assertion implementations |
@mobilewright/protocol |
Shared TypeScript driver interfaces and types |
@mobilewright/driver-mobilecli |
Driver for local and remote mobilecli devices |
@mobilewright/driver-mobilenext |
Driver for Mobile Next Cloud devices |
Install the package for your chosen workflow from Get Started. The core and local driver packages are included as dependencies where needed.
If you've used Playwright, you already know Mobilewright.
| Mobilewright | Appium | Detox | XCTest/Espresso | |
|---|---|---|---|---|
| API style | Playwright (getByRole, expect) |
Selenium (WebDriver) | Custom | Native framework |
| Auto-wait | Built-in, every action | Manual waits | Partial | Manual |
| Setup | npm install mobilewright |
Server + drivers + caps | React Native only | Xcode/AS only |
| Cross-platform | iOS + Android, one API | Yes, verbose | React Native only | Single platform |
| AI agent support | First-class (accessibility tree) | Limited | No | No |
| Real devices in the cloud | Mobile Next Cloud, BrowserStack, Sauce Labs, TestMu AI, TestingBot | Yes (complex) | Simulators only | Yes |
| Locators | Semantic roles + labels | XPath, CSS, ID | Test IDs | Native queries |
The same tests that run on a local device run on real devices in the cloud. Only the driver in mobilewright.config.ts changes. Mobilewright supports these device clouds:
- Mobile Next Cloud, built by the Mobilewright team. API access to hundreds of real Android and iOS devices, with test results uploaded to your dashboard automatically. Setup guide
- BrowserStack, App Automate sessions via the
@browserstack/mobilewrightdriver - Sauce Labs, real Android and iOS devices via the
@saucelabs/mobilewright-driverpackage - TestMu AI, real Android and iOS devices via the
@testmuai/mobilewrightdriver - TestingBot, real devices, emulators and simulators via the
@testingbot/mobilewright-driverpackage
Mobilewright collects anonymous usage telemetry via PostHog and Scarf. To disable it, set the standard DO_NOT_TRACK environment variable:
DO_NOT_TRACK=1 npx mobilewright testTo opt out permanently, set export DO_NOT_TRACK=1 in your shell profile (for example ~/.zshrc or ~/.bashrc) or set DO_NOT_TRACK=1 in your CI environment.
When telemetry is enabled, a random identifier is generated and stored in ~/.config/mobilenext/mobilewright/config.json. Mobilewright never sends personal information or test data. The Scarf pixel is a plain HTTP request, so Scarf receives the usual request metadata (source IP, user agent); Scarf states it does not retain raw IP addresses. Setting MOBILEWRIGHT_DISABLE_TELEMETRY (any value) or DO_NOT_TRACK (any value except 0 or false) opts out of both.
For Mobilewright MCP, set MOBILEMCP_DISABLE_TELEMETRY=1 in the MCP server's environment. See MCP telemetry configuration for the client configuration example.
See CONTRIBUTING.md for development setup, reporting issues, and submitting changes.
| Framework | iOS | Android | Notes |
|---|---|---|---|
| UIKit / Storyboards | ✅ | — | Full native element types, all locators work |
| SwiftUI | ✅ | — | Maps to standard XCUIElementType accessibility tree |
| Jetpack Compose | — | ✅ | Renders to native Android accessibility nodes |
| Android Views (XML layouts) | — | ✅ | Full native element types, all locators work |
| React Native | ✅ | ✅ | Uses real native components; RN-specific types mapped to roles |
| Expo | ✅ | ✅ | Same as React Native (Expo builds to RN) |
| Flutter | ✅ | ✅ | Must be a debug build for full support |
| .NET MAUI | ✅ | ✅ | Compiles to native controls on both platforms |
| Kotlin Multiplatform (shared UI) | ⏳ | ✅ | Android native works; iOS Compose Multiplatform support in progress |
| Cordova / Capacitor | ✅ | ✅ | WebView content accessible via native accessibility tree |
| NativeScript | ✅ | ✅ | Renders to native views on both platforms |
This project is licensed under the Apache License 2.0 — see the LICENSE file for details.

