An open API service indexing awesome lists of open source software.

https://github.com/sh3lan93/mobile-automator

The intelligent mobile QA extension that learns your app and writes tests for you.
https://github.com/sh3lan93/mobile-automator

gemini-cli-extension mobile-qa mobile-test-automation semantic-testing

Last synced: 3 months ago
JSON representation

The intelligent mobile QA extension that learns your app and writes tests for you.

Awesome Lists containing this project

README

          

# ๐Ÿš€ Mobile Automator

> **The intelligent mobile QA extension that learns your app and writes tests for you.**

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![Platform](https://img.shields.io/badge/Platform-Android%20%7C%20iOS%20%7C%20Flutter%20%7C%20React%20Native-green.svg)](#)
[![Powered by](https://img.shields.io/badge/Powered%20by-mobile--mcp-orange.svg)](https://github.com/mobile-next/mobile-mcp)

---

## ๐Ÿ’ก Why Mobile Automator?

**The story behind this tool:**

Every Monday, I had **4 hours blocked on my calendar** for manual regression testing. Four hours. Every single week.

That's **208 hours a year** tapping through the same flows, checking the same screens, validating the same features. Over and over again.

I realized something had to change. **I refuse to repeat myself.** My time is too valuable to waste on tasks that can be automated.

So I built Mobile Automatorโ€”not just to run tests, but to **learn from my manual testing sessions** and replay them automatically. Now, those 4 hours are spent building features instead of repeating the same test flows.

**If you're tired of manual regression testing eating your calendar, this tool is for you.** ๐ŸŽฏ

---

## โœจ What Makes This Special?

**Mobile Automator doesn't just run testsโ€”it understands your app.**

When you run setup, it analyzes your codebase and automatically detects:
- ๐Ÿ“ฑ **Platform & Architecture** - Android, iOS, Flutter, React Native, KMP, CMP
- ๐Ÿ—๏ธ **Architecture Pattern** - MVVM, Clean Architecture, BLoC, Redux, MVP
- ๐ŸŽฏ **Business Domain** - What your app actually does
- โšก **Loading Patterns** - Your specific progress indicators and shimmer effects
- ๐Ÿ”ง **Build Configuration** - Commands, flavors, environments
- ๐Ÿ“ฆ **Package IDs** - Android applicationId, iOS Bundle Identifier

Then it generates **AI-powered testing skills** customized specifically for your project.

---

## ๐ŸŽฌ See It In Action

### ๐Ÿ“ Generate Test Scenarios

https://github.com/user-attachments/assets/6be4adce-4b30-45b1-a025-0e3373e30348

**What you see:**
- ๐ŸŽฎ Describe user flows in plain English
- ๐Ÿค– AI controls your device/emulator automatically
- ๐Ÿ“ธ Captures reference screenshots at each step
- โœ๏ธ Generates structured JSON test scenarios

---

### โ–ถ๏ธ Execute Tests & Get Intelligent Reports

https://github.com/user-attachments/assets/fbc69108-0736-402c-846c-faca237fe4ca

**What you get:**
- โœ… Pass/fail status with detailed results
- ๐Ÿ” Regression detection (spots UI changes)
- โšก Flakiness detection (retries on transient failures)
- ๐Ÿง  Contextual insights (device differences, environment details)

---

## ๐ŸŽฏ Quick Start

### Prerequisites
- **Gemini CLI** installed ([Get it here](https://geminicli.com))
- **Mobile project** (Android, iOS, Flutter, React Native, KMP, or CMP)
- **Node.js** v16+ (for mobile-mcp automation engine)

### Installation

**From GitHub:**
```bash
gemini extensions install https://github.com/sh3lan93/mobile-automator
```

**Local Development:**
```bash
git clone https://github.com/sh3lan93/mobile-automator
cd mobile-automator
gemini extensions link .
```

### Setup Your Project

```bash
# Navigate to your mobile project
cd ~/projects/my-awesome-app

# Launch Gemini CLI
gemini

# Run setup
> /mobile-automator:setup
```

The setup wizard will guide you through:
1. โœ… **Platform Detection** - Identifies your tech stack
2. โœ… **Environment Discovery** - Finds staging, prod, dev configs
3. โœ… **App Package Inference** - Extracts bundle IDs
4. โœ… **Project Knowledge** - Learns your architecture and domain
5. โœ… **Skill Installation** - Generates customized testing skills
6. โœ… **Directory Scaffolding** - Creates test artifact structure

**After setup completes, reload skills:**
```bash
> /skills reload
```

**Output:**
```
mobile-automator/
โ”œโ”€โ”€ config.json # Project configuration
โ”œโ”€โ”€ index.md # Documentation
โ”œโ”€โ”€ scenarios/ # Generated test scenarios
โ”œโ”€โ”€ screenshots/ # Reference screenshots
โ””โ”€โ”€ results/ # Test execution reports

.gemini/skills/
โ”œโ”€โ”€ mobile-automator-generator/ # Your custom test generator
โ””โ”€โ”€ mobile-automator-executor/ # Your custom test runner
```

### Generate Your First Test

```bash
> /mobile-automator:generate
```

When prompted, describe the test in natural language:

**Example 1: Login Flow**
```
1. Launch the app
2. Tap on "Login" button
3. Enter email: test@example.com
4. Enter password: Test123!
5. Tap "Sign In"
6. Validate user is logged in (shows profile icon)
```

**Example 2: Conversational Style**
```
fresh install -> user opens app -> wait for splash screen ->
validate bottom navigation shows 4 tabs: home, orders, offers, more
```

**What you get:**
- ๐Ÿ“„ `mobile-automator/scenarios/login_flow.json` - Structured test scenario
- ๐Ÿ“ธ `mobile-automator/screenshots/login_flow/` - Reference screenshots
- โœ… Ready to execute on any device

### Execute Your Test

```bash
> /mobile-automator:execute login_flow
```

**You'll see:**
- โ–ถ๏ธ Real-time step execution on your device
- ๐Ÿ“Š Pass/fail status for each assertion
- ๐Ÿ” Flakiness detection and retry logic
- ๐Ÿ“ธ Screenshot comparison with visual analysis
- ๐Ÿ“ Detailed failure reports with context

---

## ๐Ÿ—๏ธ Supported Platforms

| Platform | Detection | Build Commands | Device Control |
|----------|-----------|----------------|----------------|
| **Android** | โœ… Native, Gradle | `./gradlew assembleDebug` | โœ… Emulator + Real Device |
| **iOS** | โœ… Native, Xcode | `xcodebuild -scheme MyApp` | โœ… Simulator + Real Device |
| **Flutter** | โœ… Cross-platform | `flutter build apk/ios` | โœ… All platforms |
| **React Native** | โœ… Metro bundler | `npx react-native run-android/ios` | โœ… All platforms |
| **Kotlin Multiplatform** | โœ… KMP structure | `./gradlew assembleDebug` | โœ… Android + iOS |
| **Compose Multiplatform** | โœ… CMP structure | Gradle + Xcode | โœ… Android + iOS |

---

## ๐Ÿง  Intelligent Features

### 1. Architecture Pattern Detection
Mobile Automator scans your codebase and recognizes:
- **MVVM** (ViewModel, LiveData patterns)
- **Clean Architecture** (domain, data, presentation layers)
- **BLoC** (Flutter - Business Logic Component)
- **Redux/MVI** (reducer, store, actions)
- **MVP/VIPER** (presenter, interactor patterns)

**Why it matters:** Skills are tailored to your architecture's naming conventions.

### 2. Loading Indicator Auto-Detection
Greps your source code for:
- Android: `CircularProgressIndicator`, `ShimmerEffect`, `ProgressBar`
- iOS: `UIActivityIndicatorView`, `ProgressView`, `SkeletonView`
- Flutter: `CircularProgressIndicator`, `Shimmer`
- React Native: `ActivityIndicator`, `SkeletonPlaceholder`

**Why it matters:** Tests automatically wait for your specific loading patterns.

### 3. Flakiness Detection & Diagnosis
When tests fail, the executor:
- ๐Ÿ”„ **Retries once** on suspected timing issues
- ๐Ÿ“Š **Flags flaky tests** with retry count
- ๐Ÿงช **Analyzes root cause**: loading delay, animation, network dependency
- ๐Ÿ’ก **Suggests fixes**: "Consider adding explicit wait for this step"

### 4. State-Aware Failure Analysis
Failed assertions include context:
- ๐ŸŒ“ Dark mode vs light mode mismatch
- ๐Ÿ“ฑ Device differences (Pixel 6 vs Pixel 8)
- ๐ŸŒ Network state (WiFi vs cellular)
- โŒจ๏ธ Keyboard visibility
- ๐Ÿ”„ Orientation differences

### 5. Semantic Visual Testing
Instead of brittle pixel-matching:
> "Does this screen fulfill the same purpose as the reference?"

Uses AI vision to compare screenshots semantically, not pixel-by-pixel.

---

## ๐Ÿ“‹ Commands Reference

| Command | Description | Usage | What It Does |
|---------|-------------|-------|--------------|
| **`/mobile-automator:setup`** | One-time setup - analyzes project and installs testing skills | `> /mobile-automator:setup` | โ€ข Detects platform (Android/iOS/Flutter/React Native/KMP/CMP)
โ€ข Discovers build environments (staging, production, etc.)
โ€ข Infers app package IDs from build files
โ€ข Analyzes architecture patterns and business domain
โ€ข Installs customized QA skills
โ€ข Creates `mobile-automator/` test directory
โ€ข **Resume support:** If interrupted, run again to resume |
| **`/mobile-automator:generate`** | **Record** test scenarios from natural language (do this once per test) | `> /mobile-automator:generate` | โ€ข Connects to your device/emulator
โ€ข Prompts for test steps in natural language
โ€ข Executes steps on device while recording
โ€ข Captures reference screenshots
โ€ข Generates JSON scenario file (schema v2)
**Output:** `mobile-automator/scenarios/.json` |
| **`/mobile-automator:execute`** | **Replay** saved test scenarios (run repeatedly for regression testing) | `> /mobile-automator:execute `

Examples:
โ€ข Single: `execute login_flow`
โ€ข Multiple: `execute login_flow checkout_flow`
โ€ข All: `execute` (interactive) | โ€ข Replays scenario steps on connected device
โ€ข Captures actual screenshots for comparison
โ€ข Validates assertions (element exists, text matches, visual state)
โ€ข Detects flakiness and retries automatically
โ€ข Generates detailed pass/fail report with diagnostics
**Output:** `mobile-automator/results/.json` |
| **`/mobile-automator:migrate`** | **Migrate** a v1 scenario JSON to schema v2 format | `> /mobile-automator:migrate `

Examples:
โ€ข `migrate login_flow`
โ€ข `migrate` (interactive file selection) | โ€ข Analyzes existing v1 scenario
โ€ข Auto-converts step IDs, assertion IDs, metadata
โ€ข Interactively resolves ambiguous waits
โ€ข Creates `.v1.bak` backup before any changes
โ€ข Outputs valid schema v2 scenario |
| **`/mobile-automator:list-tags`**| Lists all tags currently used in test scenarios | `> /mobile-automator:list-tags` | โ€ข Scans all JSON scenarios
โ€ข Displays tag counts
โ€ข Differentiates standard vs custom tags |
| **`/mobile-automator:report`** | Generate aggregated test reports | `> /mobile-automator:report`

Options:
โ€ข `--last N` (default 10)
โ€ข `--format table\|json\|html`
โ€ข `--junit` (JUnit XML) | โ€ข Aggregates all test results
โ€ข Shows pass rate, flaky steps, failures
โ€ข Exports to JSON, HTML, or JUnit XML
**Output:** `mobile-automator/results/report.{json,html,xml}` |

## ๐Ÿท๏ธ Tag-Based Filtering

Mobile Automator supports tagging scenarios logically (e.g. `smoke`, `regression`, `critical`) so you can execute specific subsets of your test suite.

### Adding Tags
During scenario generation (`/mobile-automator:generate`), the agent will ask you what tags describe the scenario before saving it. You can also manually add tags to the `scenario.json` file:

```json
{
"$schema_version": "2.0",
"scenario_id": "login_flow",
"tags": ["smoke", "auth", "p0"],
// ...
}
```

### Filtering Executions
Use the `--tag` parameter with `/mobile-automator:execute` to filter runs:

- **Single tag:** `/mobile-automator:execute --tag smoke`
- **Multiple tags (AND):** `/mobile-automator:execute --tag smoke,critical` (matches scenarios with BOTH tags)
- **Multiple tags (OR):** `/mobile-automator:execute --tag smoke|regression` (matches scenarios with ANY tag)
- **Exclude tags (NOT):** `/mobile-automator:execute --tag !flaky` (excludes scenarios with this tag)

If you run `/mobile-automator:execute` without arguments, the interactive menu will automatically group your scenarios by their primary tag.

### Standard Tag Registry
We recommend standardizing on these common tags:
- `smoke`: Quick validation of critical paths
- `regression`: Full feature validation
- `critical`, `p0`, `p1`: Priority levels
- `fast`, `slow`: Execution time indicators
- `flaky`: Network/timing dependent tests
- `wip`: Under development

---

## Using TestRail

**Optional:** Connect TestRail to auto-generate tests and sync results.

See [TESTRAIL.md](./TESTRAIL.md) for detailed setup and usage instructions.

---

### ๐Ÿ“ The Workflow

1. **Generate once** - Use `/mobile-automator:generate` to record test scenarios by performing actions on your device
2. **Execute many times** - Use `/mobile-automator:execute` to replay those scenarios automatically across devices/builds

---

## ๐Ÿ“‚ Project Structure

After setup, your project will have:

```
your-mobile-project/
โ”œโ”€โ”€ mobile-automator/ # Test artifacts directory
โ”‚ โ”œโ”€โ”€ config.json # Auto-generated project config
โ”‚ โ”œโ”€โ”€ index.md # Documentation
โ”‚ โ”œโ”€โ”€ scenarios/ # Test scenario JSON files
โ”‚ โ”‚ โ”œโ”€โ”€ login_flow.json
โ”‚ โ”‚ โ””โ”€โ”€ checkout_flow.json
โ”‚ โ”œโ”€โ”€ screenshots/ # Reference screenshots
โ”‚ โ”‚ โ”œโ”€โ”€ login_flow/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ step_launch_app.png
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ step_tap_login.png
โ”‚ โ”‚ โ””โ”€โ”€ checkout_flow/
โ”‚ โ””โ”€โ”€ results/ # Test execution results
โ”‚ โ”œโ”€โ”€ run_20250212_143022.json
โ”‚ โ””โ”€โ”€ run_20250212_143022/
โ”‚ โ””โ”€โ”€ screenshots/
โ”‚
โ””โ”€โ”€ .gemini/
โ””โ”€โ”€ skills/ # Generated testing skills
โ”œโ”€โ”€ mobile-automator-generator/
โ”‚ โ”œโ”€โ”€ SKILL.md # Customized for YOUR project
โ”‚ โ””โ”€โ”€ references/
โ”‚ โ”œโ”€โ”€ scenario_schema_v2.json # Schema v2 (default)
โ”‚ โ””โ”€โ”€ scenario_schema.json # Schema v1 (legacy)
โ””โ”€โ”€ mobile-automator-executor/
โ”œโ”€โ”€ SKILL.md # Customized for YOUR project
โ””โ”€โ”€ references/
โ””โ”€โ”€ result_schema.json
```

---

## ๐Ÿ”ฌ How It Works

### The 3-Tier Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ TIER 1: Extension Commands โ”‚
โ”‚ /mobile-automator:setup โ”‚
โ”‚ /mobile-automator:generate โ”‚
โ”‚ /mobile-automator:execute โ”‚
โ”‚ (Pre-flight checks, validation) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ delegates to
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ TIER 2: Workspace Skills โ”‚
โ”‚ .gemini/skills/mobile-automator-*/ โ”‚
โ”‚ (Test generation & execution logic)โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ uses
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ TIER 3: Automation Engine โ”‚
โ”‚ mobile-mcp โ”‚
โ”‚ (Device control primitives) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

**Why this design?**
- โœ… **Separation of concerns** - infrastructure vs domain logic
- โœ… **Project-specific skills** - tailored to your app
- โœ… **Portable automation** - works across platforms

---

## ๐ŸŽจ Test Scenario Schema

Test scenarios are JSON files stored in `mobile-automator/scenarios/` following **schema v2** (default). Key fields:

- **`$schema_version`**: `"2.0"` โ€” required, enables version routing
- **`scenario_id`**: Unique identifier (snake_case)
- **`name`**: Human-readable description
- **`platform`**: `"android"` | `"ios"` | `"cross-platform"`
- **`variables`**: Named variables for capturing dynamic values across steps
- **`preconditions`**: Structured object โ€” `app_state`, `device_actions`, `device_properties`
- **`steps`**: Array of actions โ€” each step has a **named string `id`** (e.g., `"tap_login"`), plus:
- 14 action types: `launch_app`, `tap`, `long_press`, `double_tap`, `type`, `swipe`, `scroll_to_element`, `press_button`, `open_url`, `wait_for_element`, `wait_for_element_gone`, `wait_for_loading_complete`, `capture_value`, `clear_app_data`
- `optional: true` + `on_failure: "skip"` โ€” for non-deterministic UI elements (dialogs, banners)
- `condition` โ€” execute step only when a device property or runtime condition is met
- `retry_policy` โ€” retry on transient failures before marking the step as failed
- `capture_to` โ€” store a dynamic value for later assertion
- `sub_steps` โ€” nested conditional sub-flow
- `wait_config` โ€” smart wait parameters (`type`, `indicator`, `timeout_ms`)
- **`assertions`**: Validation rules โ€” each has a **named string `id`** and references its step by name (`after_step`):
- 9 types: `element_exists`, `element_not_exists`, `element_text`, `screenshot_match`, `pattern_match`, `value_matches_variable`, `element_count`, `visual_state`, `text_changed`

> **Migrating from v1?** Run `/mobile-automator:migrate ` or see [MIGRATION.md](MIGRATION.md).

Generated scenarios are project-specific and include your app's context (business domain, key features).

---

## ๐Ÿ› Troubleshooting

For common issues and solutions, see **[TROUBLESHOOTING.md](TROUBLESHOOTING.md)**.

---

## ๐Ÿค Contributing

Contributions are welcome! This project is open source under Apache 2.0 license.

**Areas for contribution:**
- Additional platform support
- Enhanced architecture pattern detection
- More assertion types
- CI/CD integrations
- Visual regression testing improvements

---

## ๐Ÿ“„ License

Apache License 2.0 - See [LICENSE](LICENSE) for details.

---

## ๐Ÿ™ Acknowledgments

- **[Conductor](https://github.com/gemini-cli-extensions/conductor)** - Inspired the generator pattern and structured workflow approach
- **[mobile-mcp](https://github.com/mobile-next/mobile-mcp)** - The automation engine powering device control
- **Gemini CLI** - The AI-powered CLI platform

---

**Built with โค๏ธ for mobile QA engineers**

[Report Bug](https://github.com/sh3lan93/mobile-automator/issues) ยท [Request Feature](https://github.com/sh3lan93/mobile-automator/issues) ยท [Documentation](https://github.com/sh3lan93/mobile-automator)