> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobilerun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Test a flow and keep proof

> Test a login and checkout flow, then keep evidence of each run.

Test Sauce Demo flows or your own Android app, keep evidence, and run the same test across devices.

> [accordion] Setup (once)
>
> ```bash Python theme={null}
> pip install mobilerun-sdk
> export MOBILERUN_API_KEY=dr_sk_...   # API Keys page
> export DEVICE_ID=...                 # a ready device from the dashboard
> python example.py
> ```
>
> ```bash TypeScript theme={null}
> npm init -y && npm pkg set type=module
> npm install @mobilerun/sdk && npm install -D tsx
> export MOBILERUN_API_KEY=dr_sk_...   # API Keys page
> export DEVICE_ID=...                 # a ready device from the dashboard
> npx tsx example.ts
> ```

## Test one login

Test the public demo login and check the Products heading.

**Needs:** Cloud Android · Chrome · API key + `DEVICE_ID` · credits and device minutes · no account · one-shot, about 1 min.

> Open Sauce Demo in Chrome on my device, log in as `standard_user` with `secret_sauce`, and report whether the Products heading appears.

> [accordion] Show the code (Python and TypeScript)
>
> ```python Python theme={null}
> import os
> from pydantic import BaseModel
> from mobilerun_sdk import MobilerunSDK
>
>
> class Login(BaseModel):
>     passed: bool
>     observed_message: str
>
>
> mobilerun = MobilerunSDK()
> device = mobilerun.devices.from_id(os.environ["DEVICE_ID"])
> task = device.run(
>     task="Open https://www.saucedemo.com in Chrome. Log out if needed, then log in with standard_user and secret_sauce. Report the visible page heading as observed_message and set passed to true only if it is Products.",
>     output_schema=Login,
> )
> print("task:", task.id, flush=True)
> result = task.wait_output()
> print(result.output.model_dump_json())
> success = result.response.succeeded is True and result.output.passed and result.output.observed_message.strip().lower() == "products"
> raise SystemExit(0 if success else 1)
> ```
>
> ```typescript TypeScript theme={null}
> import { MobilerunSDK } from '@mobilerun/sdk';
> import { output } from '@mobilerun/sdk/zod';
> import { z } from 'zod/v4';
>
> const mobilerun = new MobilerunSDK();
> const device = mobilerun.devices.fromId(process.env.DEVICE_ID!);
> const task = await device.run({
>   task: 'Open https://www.saucedemo.com in Chrome. Log out if needed, then log in with standard_user and secret_sauce. Report the visible page heading as observed_message and set passed to true only if it is Products.',
>   outputSchema: output(z.object({ passed: z.boolean(), observed_message: z.string() })),
> });
> console.log('task:', task.id);
> const { output: login, response } = await task.waitOutput();
> console.log(JSON.stringify(login));
> process.exitCode = response.succeeded === true && login.passed && login.observed_message.trim().toLowerCase() === 'products' ? 0 : 1;
> ```

![Sauce Demo Products page in a checkout run](https://docs.mobilerun.ai/images/examples/test-and-prove/login-result.png)

Result

```json theme={null}
{"passed": true, "observed_message": "Products"}
```

## Test your own app

Install an APK from your app library and check that its home screen shows the expected text.

**Needs:** Ready Cloud Android device · uploaded APK · API key + `DEVICE_ID` · `APP_PACKAGE` + `EXPECTED_TEXT` · credits and device minutes · one-shot.

First, upload your APK in the [Apps library](https://docs.mobilerun.ai/apps.md), or use an app already uploaded there. Wait for processing to finish, then set `APP_PACKAGE` to its Android package name and `EXPECTED_TEXT` to text that should appear on its home screen. The SDK also exposes a signed-upload and confirmation API; this example uses the dashboard for upload.

> [accordion] Show the code (Python and TypeScript)
>
> ```python Python theme={null}
> import os
> from pydantic import BaseModel
> from mobilerun_sdk import MobilerunSDK
>
>
> class Check(BaseModel):
>     passed: bool
>     notes: str
>
>
> package = os.environ["APP_PACKAGE"]
> expected = os.environ["EXPECTED_TEXT"].strip()
> if not package.strip() or not expected:
>     raise SystemExit("Set APP_PACKAGE and EXPECTED_TEXT")
> mobilerun = MobilerunSDK()
> device = mobilerun.devices.from_id(os.environ["DEVICE_ID"])
> device.apps.install(package_name=package)
> task = device.run(
>     task=f'Open the Android app with package name {package}. Check its home screen for "{expected}". Report the visible text as notes and set passed to true only if that text appears.',
>     output_schema=Check,
> )
> print("task:", task.id, flush=True)
> result = task.wait_output()
> print(result.output.model_dump_json())
> success = result.response.succeeded is True and result.output.passed and expected.lower() in result.output.notes.lower()
> raise SystemExit(0 if success else 1)
> ```
>
> ```typescript TypeScript theme={null}
> import { MobilerunSDK } from '@mobilerun/sdk';
> import { output } from '@mobilerun/sdk/zod';
> import { z } from 'zod/v4';
>
> const packageName = process.env.APP_PACKAGE;
> const expected = process.env.EXPECTED_TEXT?.trim();
> if (!packageName?.trim() || !expected) throw new Error('Set APP_PACKAGE and EXPECTED_TEXT');
> const mobilerun = new MobilerunSDK();
> const device = mobilerun.devices.fromId(process.env.DEVICE_ID!);
> await device.apps.install({ packageName });
> const task = await device.run({
>   task: `Open the Android app with package name ${packageName}. Check its home screen for "${expected}". Report the visible text as notes and set passed to true only if that text appears.`,
>   outputSchema: output(z.object({ passed: z.boolean(), notes: z.string() })),
> });
> console.log('task:', task.id);
> const { output: check, response } = await task.waitOutput();
> console.log(JSON.stringify(check));
> process.exitCode = response.succeeded === true && check.passed && check.notes.toLowerCase().includes(expected.toLowerCase()) ? 0 : 1;
> ```

Illustrative result

```json theme={null}
{"passed": true, "notes": "Welcome to Example App"}
```

## Run a test suite with a report

Run two independent tests and save a JSON report.

**Needs:** Cloud Android · Chrome · API key + `DEVICE_ID` · credits and device minutes · public demo credentials · one-shot, several minutes.

### Test 1 · Checkout completes

The standard user completes a fictional checkout; the confirmation is the expected result.

### Test 2 · Locked-out user is blocked

The locked-out user must see the expected error: that error means the test **passes**.

> [accordion] Show the code (Python and TypeScript)
>
> ```python Python theme={null}
> import json
> import os
> from pathlib import Path
> from typing import Any
> from urllib.request import urlopen
> from pydantic import BaseModel
> from mobilerun_sdk import MobilerunSDK, Task, WaitTimeoutError
>
>
> class AgentResult(BaseModel):
>     passed: bool
>     observed_message: str
>     step_reached: str
>
>
> CASES = [
>     ("checkout", "standard_user", "Thank you for your order", "Log in, add Sauce Labs Backpack to the cart, checkout using Jane Doe and postal code 12345, and finish the order. Read the confirmation message."),
>     ("locked_out", "locked_out_user", "Sorry, this user has been locked out", "Attempt to log in and read the error message. Do not try another account."),
> ]
>
>
> def save_screenshots(task: Task[Any], name: str) -> None:
>     try:
>         folder = Path("qa-screenshots") / name
>         folder.mkdir(parents=True, exist_ok=True)
>         for index, url in enumerate(task.screenshots.list().urls):
>             with urlopen(url, timeout=30) as response:
>                 (folder / f"{index}.png").write_bytes(response.read())
>     except Exception as exc:
>         print(f"Could not save screenshots for {name}: {exc}")
>
>
> def main() -> int:
>     mobilerun = MobilerunSDK()
>     device = mobilerun.devices.from_id(os.environ["DEVICE_ID"])
>     results = []
>     timed_out = False
>     for name, username, expected, instructions in CASES:
>         task = None
>         result = {"name": name, "passed": False, "observed_message": "", "step_reached": "not started", "task_id": None, "error": None}
>         if timed_out:
>             result["error"] = "Skipped because the previous task may still be running"
>             results.append(result)
>             print(f"{name}: FAIL — skipped")
>             continue
>         try:
>             task = device.run(
>                 task=(f"Open Chrome and go to https://www.saucedemo.com. Log out if already signed in. "
>                       f"Use username {username} and password secret_sauce. {instructions} "
>                       f'Report passed true only if the observed message contains "{expected}"; '
>                       "always report the actual observed_message and the last step_reached."),
>                 max_steps=50,
>                 output_schema=AgentResult,
>             )
>             result["task_id"] = task.id
>             waited = task.wait_output()
>             out = waited.output
>             result["observed_message"] = out.observed_message
>             result["step_reached"] = out.step_reached
>             result["passed"] = out.passed and expected.lower() in out.observed_message.lower() and bool(out.step_reached.strip())
>             if not result["passed"]:
>                 result["error"] = waited.response.message or "Assertion failed"
>         except Exception as exc:
>             timed_out = isinstance(exc, WaitTimeoutError)
>             result["error"] = str(exc)
>         if not result["passed"] and task:
>             save_screenshots(task, name)
>         results.append(result)
>         print(f'{name}: {"PASS" if result["passed"] else "FAIL"} — {result["observed_message"]}')
>     Path("qa-report.json").write_text(json.dumps(results, indent=2) + "\n")
>     print(f'{sum(bool(r["passed"]) for r in results)}/{len(results)} passed; report: qa-report.json')
>     return 0 if all(r["passed"] for r in results) else 1
>
>
> if __name__ == "__main__":
>     raise SystemExit(main())
> ```
>
> ```typescript TypeScript theme={null}
> import { mkdir, writeFile } from 'node:fs/promises';
> import { MobilerunSDK, WaitTimeoutError, type Task } from '@mobilerun/sdk';
> import { output } from '@mobilerun/sdk/zod';
> import { z } from 'zod/v4';
>
> type Report = { name: string; passed: boolean; observed_message: string; step_reached: string; task_id: string | null; error: string | null };
>
> const cases = [
>   { name: 'checkout', username: 'standard_user', expected: 'Thank you for your order', instructions: 'Log in, add Sauce Labs Backpack to the cart, checkout using Jane Doe and postal code 12345, and finish the order. Read the confirmation message.' },
>   { name: 'locked_out', username: 'locked_out_user', expected: 'Sorry, this user has been locked out', instructions: 'Attempt to log in and read the error message. Do not try another account.' },
> ];
> const agentResult = output(z.object({ passed: z.boolean(), observed_message: z.string(), step_reached: z.string() }));
>
> async function saveScreenshots(screenshots: Task['screenshots'], name: string): Promise<void> {
>   try {
>     const folder = `qa-screenshots/${name}`;
>     await mkdir(folder, { recursive: true });
>     for (const [index, url] of (await screenshots.list()).urls.entries()) {
>       const response = await fetch(url);
>       if (!response.ok) throw new Error(`Screenshot download failed: ${response.status}`);
>       await writeFile(`${folder}/${index}.png`, Buffer.from(await response.arrayBuffer()));
>     }
>   } catch (error) {
>     console.error(`Could not save screenshots for ${name}: ${error}`);
>   }
> }
>
> const mobilerun = new MobilerunSDK();
> const device = mobilerun.devices.fromId(process.env.DEVICE_ID!);
> const results: Report[] = [];
> let timedOut = false;
> for (const test of cases) {
>   const result: Report = { name: test.name, passed: false, observed_message: '', step_reached: 'not started', task_id: null, error: null };
>   if (timedOut) {
>     result.error = 'Skipped because the previous task may still be running';
>     results.push(result);
>     console.log(`${test.name}: FAIL — skipped`);
>     continue;
>   }
>   let screenshots: Task['screenshots'] | undefined;
>   try {
>     const task = await device.run({
>       task: `Open Chrome and go to https://www.saucedemo.com. Log out if already signed in. Use username ${test.username} and password secret_sauce. ${test.instructions} Report passed true only if the observed message contains "${test.expected}"; always report the actual observed_message and the last step_reached.`,
>       maxSteps: 50,
>       outputSchema: agentResult,
>     });
>     screenshots = task.screenshots;
>     result.task_id = task.id;
>     const { output: out, response } = await task.waitOutput();
>     result.observed_message = out.observed_message;
>     result.step_reached = out.step_reached;
>     result.passed = out.passed && out.observed_message.toLowerCase().includes(test.expected.toLowerCase()) && out.step_reached.trim().length > 0;
>     if (!result.passed) result.error = response.message || 'Assertion failed';
>   } catch (error) {
>     timedOut = error instanceof WaitTimeoutError;
>     result.error = String(error);
>   }
>   if (!result.passed && screenshots) await saveScreenshots(screenshots, test.name);
>   results.push(result);
>   console.log(`${test.name}: ${result.passed ? 'PASS' : 'FAIL'} — ${result.observed_message}`);
> }
> await writeFile('qa-report.json', JSON.stringify(results, null, 2) + '\n');
> console.log(`${results.filter((result) => result.passed).length}/${results.length} passed; report: qa-report.json`);
> if (results.some((result) => !result.passed)) process.exitCode = 1;
> ```

![Sauce Demo checkout confirmation](https://docs.mobilerun.ai/images/examples/test-and-prove/suite-result.png)

Result

```text theme={null}
checkout: PASS — Thank you for your order!
locked_out: PASS — Epic sadface: Sorry, this user has been locked out.
2/2 passed; report: qa-report.json
```

> [accordion] Run in GitHub Actions
>
> ```yaml theme={null}
> name: Checkout QA
> on: workflow_dispatch
> jobs:
>   qa:
>     runs-on: ubuntu-latest
>     steps:
>       - uses: actions/checkout@v4
>       - uses: actions/setup-python@v5
>         with:
>           python-version: '3.12'
>       - run: pip install mobilerun-sdk
>       - run: python example.py
>         env:
>           MOBILERUN_API_KEY: ${{ secrets.MOBILERUN_API_KEY }}
>           DEVICE_ID: ${{ vars.DEVICE_ID }}
>       - uses: actions/upload-artifact@v4
>         if: always()
>         with:
>           name: qa-results
>           path: |
>             qa-report.json
>             qa-screenshots/
>           if-no-files-found: warn
> ```

## Keep video and screenshots as proof

Save each test's screenshots, trajectory, and, when supported, the [recording](https://docs.mobilerun.ai/sdk/helpers.md#recordings) video in `evidence/<test>/`.

**Needs:** Cloud Android · Chrome · API key + `DEVICE_ID` · credits and device minutes · recording capability for video · public demo credentials · one-shot, several minutes.

> [accordion] Show the code (Python and TypeScript)
>
> ```python Python theme={null}
> import json
> import os
> from pathlib import Path
> from typing import Any
> from urllib.request import urlopen
> from pydantic import BaseModel
> from mobilerun_sdk import MobilerunSDK, Device, Task, WaitTimeoutError
>
>
> class AgentResult(BaseModel):
>     passed: bool
>     observed_message: str
>     step_reached: str
>
>
> CASES = [
>     ("checkout", "standard_user", "Thank you for your order", "Log in, add Sauce Labs Backpack to the cart, checkout using Jane Doe and postal code 12345, and finish the order. Read the confirmation message."),
>     ("locked_out", "locked_out_user", "Sorry, this user has been locked out", "Attempt to log in and read the error message. Do not try another account."),
> ]
>
>
> def save_screenshots(task: Task[Any], folder: Path) -> int:
>     folder.mkdir(parents=True, exist_ok=True)
>     urls = task.screenshots.list().urls
>     for index, url in enumerate(urls):
>         with urlopen(url, timeout=30) as response:
>             (folder / f"{index}.png").write_bytes(response.read())
>     return len(urls)
>
>
> def save_evidence(device: Device, task: Task[Any], recording_id: str | None, name: str, recording_supported: bool) -> None:
>     folder = Path("evidence") / name
>     folder.mkdir(parents=True, exist_ok=True)
>     (folder / "trajectory.json").write_text(task.get_trajectory().model_dump_json(indent=2))
>     count = save_screenshots(task, folder)
>     if recording_supported:
>         if not recording_id:
>             raise RuntimeError("Task did not return a recording ID")
>         recording = device.recordings.from_id(recording_id)
>         recording.wait()  # returns once the video is uploaded
>         (folder / "video.mp4").write_bytes(recording.video())
>     print(f"evidence: {folder} ({count} screenshots)")
>
>
> def main() -> int:
>     mobilerun = MobilerunSDK()
>     device = mobilerun.devices.from_id(os.environ["DEVICE_ID"])
>     recording_supported = device.retrieve_capabilities().capabilities.recording
>     print(f"Recording supported: {recording_supported}")
>     results = []
>     timed_out = False
>     for name, username, expected, instructions in CASES:
>         task = None
>         result = {"name": name, "passed": False, "observed_message": "", "step_reached": "not started", "task_id": None, "error": None}
>         if timed_out:
>             result["error"] = "Skipped because the previous task may still be running"
>             results.append(result)
>             print(f"{name}: FAIL — skipped")
>             continue
>         try:
>             task = device.run(
>                 task=(f"Open Chrome and go to https://www.saucedemo.com. Log out if already signed in. "
>                       f"Use username {username} and password secret_sauce. {instructions} "
>                       f'Report passed true only if the observed message contains "{expected}"; '
>                       "always report the actual observed_message and the last step_reached."),
>                 max_steps=50,
>                 output_schema=AgentResult,
>                 recording_enabled=recording_supported,
>             )
>             result["task_id"] = task.id
>             waited = task.wait_output()
>             out = waited.output
>             result["observed_message"] = out.observed_message
>             result["step_reached"] = out.step_reached
>             result["passed"] = out.passed and expected.lower() in out.observed_message.lower() and bool(out.step_reached.strip())
>             save_evidence(device, task, waited.response.recording_id, name, recording_supported)
>             if not result["passed"]:
>                 result["error"] = waited.response.message or "Assertion failed"
>         except Exception as exc:
>             result["passed"] = False
>             timed_out = isinstance(exc, WaitTimeoutError)
>             result["error"] = str(exc)
>         results.append(result)
>         print(f'{name}: {"PASS" if result["passed"] else "FAIL"} — {result["observed_message"]}')
>     Path("qa-report.json").write_text(json.dumps(results, indent=2) + "\n")
>     print(f'{sum(bool(r["passed"]) for r in results)}/{len(results)} passed; report: qa-report.json')
>     return 0 if all(r["passed"] for r in results) else 1
>
>
> if __name__ == "__main__":
>     raise SystemExit(main())
> ```
>
> ```typescript TypeScript theme={null}
> import { mkdir, writeFile } from 'node:fs/promises';
> import { MobilerunSDK, WaitTimeoutError, type Device, type Task } from '@mobilerun/sdk';
> import { output } from '@mobilerun/sdk/zod';
> import { z } from 'zod/v4';
>
> type Report = { name: string; passed: boolean; observed_message: string; step_reached: string; task_id: string | null; error: string | null };
>
> const cases = [
>   { name: 'checkout', username: 'standard_user', expected: 'Thank you for your order', instructions: 'Log in, add Sauce Labs Backpack to the cart, checkout using Jane Doe and postal code 12345, and finish the order. Read the confirmation message.' },
>   { name: 'locked_out', username: 'locked_out_user', expected: 'Sorry, this user has been locked out', instructions: 'Attempt to log in and read the error message. Do not try another account.' },
> ];
> const agentResult = output(z.object({ passed: z.boolean(), observed_message: z.string(), step_reached: z.string() }));
>
> async function saveEvidence(device: Device, task: Task<unknown>, recordingId: string | null | undefined, name: string, recordingSupported: boolean): Promise<void> {
>   const folder = `evidence/${name}`;
>   await mkdir(folder, { recursive: true });
>   await writeFile(`${folder}/trajectory.json`, JSON.stringify(await task.getTrajectory(), null, 2));
>   const { urls } = await task.screenshots.list();
>   for (const [index, url] of urls.entries()) {
>     const response = await fetch(url);
>     if (!response.ok) throw new Error(`Screenshot download failed: ${response.status}`);
>     await writeFile(`${folder}/${index}.png`, Buffer.from(await response.arrayBuffer()));
>   }
>   if (recordingSupported) {
>     if (!recordingId) throw new Error('Task did not return a recording ID');
>     const recording = device.recordings.fromId(recordingId);
>     await recording.wait(); // returns once the video is uploaded
>     await writeFile(`${folder}/video.mp4`, await recording.video());
>   }
>   console.log(`evidence: ${folder} (${urls.length} screenshots)`);
> }
>
> const mobilerun = new MobilerunSDK();
> const device = mobilerun.devices.fromId(process.env.DEVICE_ID!);
> const recordingSupported = (await device.retrieveCapabilities()).capabilities.recording;
> console.log(`Recording supported: ${recordingSupported}`);
> const results: Report[] = [];
> let timedOut = false;
> for (const test of cases) {
>   const result: Report = { name: test.name, passed: false, observed_message: '', step_reached: 'not started', task_id: null, error: null };
>   if (timedOut) {
>     result.error = 'Skipped because the previous task may still be running';
>     results.push(result);
>     console.log(`${test.name}: FAIL — skipped`);
>     continue;
>   }
>   try {
>     const task = await device.run({
>       task: `Open Chrome and go to https://www.saucedemo.com. Log out if already signed in. Use username ${test.username} and password secret_sauce. ${test.instructions} Report passed true only if the observed message contains "${test.expected}"; always report the actual observed_message and the last step_reached.`,
>       maxSteps: 50,
>       outputSchema: agentResult,
>       recordingEnabled: recordingSupported,
>     });
>     result.task_id = task.id;
>     const { output: out, response } = await task.waitOutput();
>     result.observed_message = out.observed_message;
>     result.step_reached = out.step_reached;
>     result.passed = out.passed && out.observed_message.toLowerCase().includes(test.expected.toLowerCase()) && out.step_reached.trim().length > 0;
>     await saveEvidence(device, task, response.recordingId, test.name, recordingSupported);
>     if (!result.passed) result.error = response.message || 'Assertion failed';
>   } catch (error) {
>     result.passed = false;
>     timedOut = error instanceof WaitTimeoutError;
>     result.error = String(error);
>   }
>   results.push(result);
>   console.log(`${test.name}: ${result.passed ? 'PASS' : 'FAIL'} — ${result.observed_message}`);
> }
> await writeFile('qa-report.json', JSON.stringify(results, null, 2) + '\n');
> console.log(`${results.filter((result) => result.passed).length}/${results.length} passed; report: qa-report.json`);
> if (results.some((result) => !result.passed)) process.exitCode = 1;
> ```

![Checkout confirmation captured during a recorded test](https://docs.mobilerun.ai/images/examples/test-and-prove/evidence-result.png)

Result

```text theme={null}
Recording supported: True
evidence: evidence/checkout (19 screenshots)
checkout: PASS
evidence: evidence/locked_out (11 screenshots)
locked_out: PASS
2/2 passed; report: qa-report.json
```

## Run it on many devices

> [!TIP]
>
> Run the suite on as many devices as you need: one report per device, all in parallel.

Run the login test concurrently on distinct devices and print one result per device.

**Needs:** Ready Cloud Android devices · Chrome · API key + comma-separated `DEVICE_IDS` · credits and device minutes per device · public demo credentials · one-shot.

> [accordion] Show the code (Python and TypeScript)
>
> ```python Python theme={null}
> import asyncio
> import json
> import os
> from pydantic import BaseModel
> from mobilerun_sdk import AsyncMobilerunSDK
>
>
> class Login(BaseModel):
>     passed: bool
>     observed_message: str
>
>
> mobilerun = AsyncMobilerunSDK()
> ids = [value.strip() for value in os.environ["DEVICE_IDS"].split(",") if value.strip()]
> if not ids or len(set(ids)) != len(ids):
>     raise SystemExit("Set DEVICE_IDS to distinct, comma-separated device IDs")
>
>
> async def test_login(device_id: str) -> dict:
>     try:
>         device = mobilerun.devices.from_id(device_id)
>         task = await device.run(
>             task="Open https://www.saucedemo.com in Chrome. Log out if needed, then log in with standard_user and secret_sauce. Report the visible page heading as observed_message and set passed to true only if it is Products.",
>             output_schema=Login,
>         )
>         result = await task.wait_output()
>         message = result.output.observed_message
>         passed = result.response.succeeded is True and result.output.passed and message.strip().lower() == "products"
>         return {"device_id": device_id, "passed": passed, "observed_message": message, "task_id": task.id}
>     except Exception as exc:
>         return {"device_id": device_id, "passed": False, "error": str(exc)}
>
>
> async def main() -> None:
>     results = await asyncio.gather(*(test_login(i) for i in ids))
>     for row in results:
>         print(json.dumps(row))
>     raise SystemExit(0 if all(row["passed"] for row in results) else 1)
>
>
> asyncio.run(main())
> ```
>
> ```typescript TypeScript theme={null}
> import { MobilerunSDK } from '@mobilerun/sdk';
> import { output } from '@mobilerun/sdk/zod';
> import { z } from 'zod/v4';
>
> const ids = (process.env.DEVICE_IDS ?? '').split(',').map(id => id.trim()).filter(Boolean);
> if (!ids.length || new Set(ids).size !== ids.length) throw new Error('Set DEVICE_IDS to distinct, comma-separated device IDs');
> const mobilerun = new MobilerunSDK();
> const results = await Promise.allSettled(ids.map(async deviceId => {
>   const task = await mobilerun.devices.fromId(deviceId).run({
>     task: 'Open https://www.saucedemo.com in Chrome. Log out if needed, then log in with standard_user and secret_sauce. Report the visible page heading as observed_message and set passed to true only if it is Products.',
>     outputSchema: output(z.object({ passed: z.boolean(), observed_message: z.string() })),
>   });
>   const { output: login, response } = await task.waitOutput();
>   const passed = response.succeeded === true && login.passed && login.observed_message.trim().toLowerCase() === 'products';
>   return { device_id: deviceId, passed, observed_message: login.observed_message, task_id: task.id };
> }));
> let failed = false;
> for (const [i, result] of results.entries()) {
>   const row = result.status === 'fulfilled' ? result.value : { device_id: ids[i], passed: false, error: String(result.reason) };
>   console.log(JSON.stringify(row));
>   if (!row.passed) failed = true;
> }
> if (failed) process.exitCode = 1;
> ```

Result

| Device | Result | Observed |
| - | - | - |
| Docs test A | PASS | Products |
| Docs test B | PASS | Products |

## Next steps

* [Inspect task history and trajectories](https://docs.mobilerun.ai/tasks.md).
* [Configure structured output](https://docs.mobilerun.ai/agent.md#structured-output).
* [Review task screenshots](https://docs.mobilerun.ai/api-reference/screenshots/get-task-screenshots.md).

> [accordion] For AI agents
>
> Start with the login test, or upload an APK to the app library and test it by package name. Use task run, status, screenshots and trajectory APIs. Sauce Demo credentials are public demo credentials. Report results for each test and device.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.