MobileWright: Playwright Finally Comes to Mobile
The open-source framework bringing Playwright's beloved developer experience β auto-wait, semantic locators, TypeScript-first β to iOS and Android. And it's built for AI agents.
TL;DR
MobileWright is an open-source TypeScript framework that gives you a Playwright-like API for iOS and Android. It's deterministic, agent-friendly (no vision model needed), and works across UIKit, SwiftUI, React Native, and Expo.
The Mobile Automation Problem
Web test automation has a clear winner in 2026: Playwright. Developers love its auto-wait mechanism, semantic locators (getByRole, getByLabel), and rock-solid TypeScript support.
Mobile has no equivalent. Appium is powerful but verbose and inherently fragile. XCUITest and Espresso are platform-specific. Detox works for React Native but struggles with native UI layers. And all of these frameworks make AI agent integration a nightmare β they require coordinate-based clicks or opaque XPath selectors that LLMs can't reason about.
MobileWright aims to fix this.
What Is MobileWright?
MobileWright (mobilewright.dev) is an open-source mobile automation framework with a unified TypeScript API for both iOS and Android. Instead of relying on fragile coordinates or XPath, it exposes the device's accessibility tree β the same semantic structure that screen readers use.
This has two massive benefits:
- Human-readable, resilient locators: Find elements by role, label, or text β just like Playwright for the web.
- AI agent-friendly: AI agents (Claude, GPT-4, Gemini) can interact with your app using readable commands without needing expensive screenshot-based vision models.
MobileWright vs. Appium: A Quick Comparison
| Feature | MobileWright | Appium |
|---|---|---|
| API style | Playwright-like (modern) | WebDriver (older) |
| Language | TypeScript-first | Any (Python, Java, JS...) |
| Locator strategy | Semantic (getByRole, getByLabel) | XPath, accessibility ID |
| Auto-wait | β Built-in | π§ Manual waits required |
| AI agent-ready | β Exposes accessibility tree | β οΈ Coordinate-based by default |
| Setup complexity | π’ Zero-config CLI | π΄ Server + driver setup |
| Platform support | iOS + Android | iOS + Android + Desktop |
| React Native / Expo | β Full support | β Partial support |
Code Example: Your First MobileWright Test
Here's how clean a MobileWright test looks compared to traditional Appium:
β MobileWright
import { test, expect } from '@mobilewright/test';
test('login flow', async ({ device }) => {
await device
.getByLabel('Username')
.fill('john@example.com');
await device
.getByLabel('Password')
.fill('secret123');
await device
.getByRole('button', { name: 'Sign In' })
.tap();
await expect(
device.getByText('Welcome back, John')
).toBeVisible();
});π§ Appium equivalent
const username = await driver.findElement(
By.xpath('//XCUIElementTypeTextField')
);
await username.sendKeys('john@example.com');
const password = await driver.findElement(
By.xpath('//XCUIElementTypeSecureTextField')
);
await password.sendKeys('secret123');
const loginBtn = await driver.findElement(
By.accessibilityId('sign-in-button')
);
await loginBtn.click();
await driver.waitUntil(async () => {
const el = await driver.findElement(
By.xpath('//*[@label="Welcome back, John"]')
);
return await el.isDisplayed();
}, { timeout: 5000 });The AI Agent Superpower
This is where MobileWright gets genuinely exciting. Because it exposes the accessibility tree rather than coordinates, you can connect AI agents directly to your mobile app.
Imagine prompting Claude: "Navigate to the checkout screen and verify the order total matches the cart" β and having the agent execute it on a real iOS simulator, using getByRole and getByLabel locators without needing to process a single screenshot.
Why This Matters for AI Testing
Vision-model approaches (where AI "sees" a screenshot and clicks coordinates) are expensive, slow, and brittle. MobileWright's accessibility-tree approach lets AI agents operate with the same efficiency as web automation β no screenshot parsing needed, just semantic commands.
Getting Started
- Install the CLI:
npm init mobilewright@latest ./
- Auto-discover simulators: The CLI automatically finds connected devices and running simulators β no configuration needed.
- Run your tests:
npx mobilewright test
Full docs at mobilewright.dev and the source on GitHub.
Should You Adopt It?
β Great fit if you...
- β’ Already use Playwright for web automation
- β’ Are building AI-agent driven test pipelines
- β’ Work with React Native / Expo apps
- β’ Want modern TypeScript DX for mobile
β οΈ Stick with Appium if you...
- β’ Need mature enterprise support
- β’ Rely heavily on non-JS languages (Java/Python)
- β’ Test deeply native, non-accessible UI
- β’ Need desktop app automation too
MobileWright is still early (open-source, not yet v1.0), but its trajectory is exciting. As AI-agent-driven testing becomes standard, a framework that's purpose-built for that paradigm has a massive advantage.
Continue Learning