Advanced: Wikipedia on Android

Explore a complete example using Maestro and Wikipedia App. Use subflows, interactive scrolling, and JavaScript for robust, data-driven mobile automation.

This guide demonstrates how to use Maestro to automate complex user journeys in the Wikipedia Android app. You will learn how to manage multi-step onboarding, interact with dynamic feeds using scrolling, and integrate JavaScript for data-driven testing.

Prerequisites

Before starting, ensure you have the project files and the app ready:

  1. Install Maestro CLI: Follow the installation guide.

  2. Download Samples: Run maestro download-samples to fetch the source code and the wikipedia.apk.

  3. Navigate to Project: Open your terminal and enter the directory after download the samples (cd wikipedia-android-advanced).

Project Structure

The project is organized into subflows to ensure maintainability and reusability across different test suites:

├── run-test.yml           # Root test suite orchestrator
├── onboarding/            # App initialization flows
├── dashboard/             # Feed and navigation flows
├── auth/                  # Login and signup flows
└── scripts/               # JavaScript for dynamic data generation

1. Onboarding Flow

The onboarding subflow handles the initial setup of the application. By using clearState: true, the test ensures a fresh installation state, which is critical for verifying that new users can navigate the language settings and introductory screens without interference from previous sessions.

This Flow serves as the entry point for the onboarding sequence. It orchestrates the addition and removal of languages before progressing through the introductory informational screens like "New ways to explore" and "Reading lists".

# onboarding/main.yml
appId: org.wikipedia
---
- runFlow: "add-language.yml"
- runFlow: "remove-language.yml"
- tapOn: "Continue"
- assertVisible: "New ways to explore"
- tapOn: "Continue"
- assertVisible: "Reading lists with sync"
- tapOn: "Continue"
- assertVisible: "Send anonymous data"
- tapOn: "Get started"

2. Dashboard Navigation

The dashboard contains dynamic content that varies daily. These tests illustrate how to interact with elements that are not immediately visible on the screen and how to share data between different views using the system clipboard.

This orchestrator Flow for the dashboard sequentially executes tests for searching, checking saved articles, interacting with the feed, and performing copy-paste operations.

3. Authentication and scripting

Maestro supports JavaScript execution to handle logic that is difficult to achieve with YAML alone. These examples show how to generate unique registration data and fetch valid test credentials from an external API.

This test automates the account creation form by running generateCredentials.js to populate the username, password, and email fields with unique data.

Running the test

To run the entire end-to-end journey, use the run-test.yml file.

This Flow ensures that the app is launched in a clean state before executing the onboarding, dashboard navigation, and authentication flows in sequence.

  • Nested Flows: Build modular, reusable tests by embedding existing Flows into complex user journeys.

  • inputText: Learn how to simulate realistic keyboard entries.

  • Make HTTP requests: Make HTTP API calls from your flows to set up test data or verify backend state.

  • JavaScript overview: Unlock advanced logic and conditional testing power by integrating scripts into your YAML.

Last updated