Skip to content

Commit 1c064d3

Browse files
authored
Add document for UI testing with Maestro (simpledotorg#4332)
* Add document for UI testing with Maestro * Update document with context and link to example * Update line spacing * Update document context * Update context and add code examples
1 parent b1fddde commit 1c064d3

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

doc/ui-testing-with-maestro.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
3+
# UI testing with Maestro
4+
5+
We cannot detect crashes that occur while navigating through the screens, opening the app, incompatible image assets etc with the help of Unit or Integration tests. Opening and navigating through the app manually is the only way to identify them. Crashes like these can be detected via UI tests where we write tests for a set of screen interactions. We use Maestro for UI testing in Simple as it offers a single binary tool that works anywhere with declarative yet robust syntax and has a quick learning curve.
6+
7+
## Install the Maestro CLI
8+
9+
Setup Maestro CLI on the system with the [Homebrew](https://brew.sh/)
10+
11+
brew tap mobile-dev-inc/tap
12+
brew install maestro
13+
14+
## Understating Flows
15+
16+
A **Flow** is a series of steps that tell Maestro how to navigate the application. Here are some commonly used steps in a flow.
17+
18+
- [`clearState`](https://maestro.mobile.dev/reference/app-files) - *clears the application state*
19+
- [`launchApp`](https://maestro.mobile.dev/reference/app-lifecycle) - *launches the app*
20+
- [`tapOn`](https://maestro.mobile.dev/reference/tap-on-view) - *taps on a view on the screen*
21+
- [`assertVisible`](https://maestro.mobile.dev/reference/assertions) - *asserts whether an element is visible*
22+
- [`inputText`](https://maestro.mobile.dev/reference/text-input) - *inputs text*
23+
24+
More Maestro flow commands can be found [here](https://maestro.mobile.dev/).
25+
26+
Below is an example of how to test login flow in Simple. Flow can be found [here](https://github.com/simpledotorg/simple-android/blob/master/maestroUiFlows/login_flow.yaml)
27+
28+
appId: org.simple.clinic.staging
29+
---
30+
- clearState
31+
- launchApp
32+
- tapOn: "Next"
33+
- tapOn: "Get started"
34+
- tapOn:
35+
below:
36+
id: "select_country_title"
37+
- tapOn:
38+
below:
39+
id: "select_state_title"
40+
- inputText: ${number}
41+
- tapOn: "Next"
42+
- assertVisible:
43+
text: "Your security PIN"
44+
- inputText: ${pin}
45+
- tapOn: "Enter code"
46+
- inputText: ${otp}
47+
- tapOn: "Got it"
48+
49+
50+
## Running a Flow
51+
52+
Flow can be run using the `maestro test` command.
53+
54+
maestro test login_flow.yaml
55+
56+
Params to the flow can be given from the terminal as given below
57+
58+
maestro test -e number=0123456789 -e pin=0000 -e otp=000000 uiFlows/login_flow.yaml

0 commit comments

Comments
 (0)