Skip to content

Commit c5ae3b6

Browse files
committed
Add docs for assertEqual and assertNotEqual commands
1 parent 2f36141 commit c5ae3b6

4 files changed

Lines changed: 213 additions & 0 deletions

File tree

SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
* [assertTrue](api-reference/commands/asserttrue.md)
8888
* [assertWithAI](api-reference/commands/assertwithai.md)
8989
* [assertNoDefectsWithAi](api-reference/commands/assertnodefectswithai.md)
90+
* [assertEqual](api-reference/commands/assertequal.md)
91+
* [assertNotEqual](api-reference/commands/assertnotequal.md)
9092
* [back](api-reference/commands/back.md)
9193
* [clearKeychain](api-reference/commands/clearkeychain.md)
9294
* [clearState](api-reference/commands/clearstate.md)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
description: Assert that two values are equal in Maestro flows.
3+
---
4+
5+
# assertEqual
6+
7+
Asserts that two values are equal after JavaScript evaluation:
8+
9+
```yaml
10+
- assertEqual:
11+
value1: ${actualValue}
12+
value2: "expected"
13+
```
14+
15+
This command compares `value1` and `value2` as strings after evaluating any JavaScript expressions. If the values are not equal, the assertion fails with a clear error message showing both values.
16+
17+
### Basic usage
18+
19+
Compare a variable to an expected value:
20+
21+
```yaml
22+
- assertEqual:
23+
value1: ${output.username}
24+
value2: "john_doe"
25+
```
26+
27+
Compare two JavaScript expressions:
28+
29+
```yaml
30+
- assertEqual:
31+
value1: ${2 + 2}
32+
value2: ${8 - 4}
33+
```
34+
35+
Compare text copied from the UI:
36+
37+
```yaml
38+
- copyTextFrom:
39+
id: "price-label"
40+
- assertEqual:
41+
value1: ${maestro.copiedText}
42+
value2: "$19.99"
43+
```
44+
45+
### With label and optional
46+
47+
Add a descriptive label or make the assertion optional:
48+
49+
```yaml
50+
- assertEqual:
51+
value1: ${output.status}
52+
value2: "success"
53+
label: "Verify API returned success status"
54+
optional: true
55+
```
56+
57+
### Use in conditions
58+
59+
`assertEqual` can be used in `runFlow` and `repeat` conditions:
60+
61+
```yaml
62+
- runFlow:
63+
when:
64+
equal:
65+
value1: ${platform}
66+
value2: "ios"
67+
commands:
68+
- tapOn: "iOS-specific button"
69+
```
70+
71+
```yaml
72+
- repeat:
73+
while:
74+
equal:
75+
value1: ${output.loading}
76+
value2: "true"
77+
commands:
78+
- waitForAnimationToEnd
79+
```
80+
81+
### Considerations
82+
83+
`assertNotEqual` compares values as strings after JavaScript evaluation:
84+
85+
- **Numbers are normalized**: `${1}` and `${1.0}` both evaluate to `"1"` and will match
86+
- **Booleans become strings**: `${true}` evaluates to `"true"`
87+
88+
This means `${true}` and `${1}` are not considered equal — they evaluate to `"true"` and `"1"` respectively. If you need JavaScript type coercion (where `1 == true`), use `assertTrue`:
89+
90+
```yaml
91+
- assertTrue: ${1 == true}
92+
```
93+
94+
### Related commands
95+
96+
{% content-ref url="assertnotequal.md" %}
97+
[assertnotequal.md](assertnotequal.md)
98+
{% endcontent-ref %}
99+
100+
{% content-ref url="asserttrue.md" %}
101+
[asserttrue.md](asserttrue.md)
102+
{% endcontent-ref %}
103+
104+
{% content-ref url="assertvisible.md" %}
105+
[assertvisible.md](assertvisible.md)
106+
{% endcontent-ref %}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
description: Assert that two values are not equal in Maestro flows.
3+
---
4+
5+
# assertNotEqual
6+
7+
Asserts that two values are not equal after JavaScript evaluation:
8+
9+
```yaml
10+
- assertNotEqual:
11+
value1: "foo"
12+
value2: "bar"
13+
```
14+
15+
This command compares `value1` and `value2` as strings after evaluating any JavaScript expressions. If the values are equal, the assertion fails.
16+
17+
### Basic usage
18+
19+
Ensure a value is not a specific string:
20+
21+
```yaml
22+
- assertNotEqual:
23+
value1: ${output.status}
24+
value2: "error"
25+
```
26+
27+
Verify UI text has changed:
28+
29+
```yaml
30+
- copyTextFrom:
31+
id: "counter"
32+
- evalScript: ${output.initialCount = maestro.copiedText}
33+
- tapOn: "Increment"
34+
- copyTextFrom:
35+
id: "counter"
36+
- assertNotEqual:
37+
value1: ${maestro.copiedText}
38+
value2: ${output.initialCount}
39+
label: "Counter should have changed"
40+
```
41+
42+
### With label and optional
43+
44+
```yaml
45+
- assertNotEqual:
46+
value1: ${output.userId}
47+
value2: ""
48+
label: "User ID should not be empty"
49+
optional: true
50+
```
51+
52+
### Use in conditions
53+
54+
`assertNotEqual` can be used in `runFlow` and `repeat` conditions:
55+
56+
```yaml
57+
- runFlow:
58+
when:
59+
notEqual:
60+
value1: ${output.status}
61+
value2: "disabled"
62+
commands:
63+
- tapOn: "Submit"
64+
```
65+
66+
```yaml
67+
- repeat:
68+
while:
69+
notEqual:
70+
value1: ${output.loading}
71+
value2: "false"
72+
commands:
73+
- waitForAnimationToEnd
74+
```
75+
76+
### Considerations
77+
78+
`assertNotEqual` compares values as strings after JavaScript evaluation:
79+
80+
- **Numbers are normalized**: `${1}` and `${1.0}` both evaluate to `"1"` and will match
81+
- **Booleans become strings**: `${true}` evaluates to `"true"`
82+
83+
This means `${true}` and `${1}` are not considered equal — they evaluate to `"true"` and `"1"` respectively. If you need JavaScript type coercion (where `1 == true`), use `assertTrue`:
84+
85+
```yaml
86+
- assertTrue: ${1 == true}
87+
```
88+
89+
### Related commands
90+
91+
{% content-ref url="assertequal.md" %}
92+
[assertequal.md](assertequal.md)
93+
{% endcontent-ref %}
94+
95+
{% content-ref url="asserttrue.md" %}
96+
[asserttrue.md](asserttrue.md)
97+
{% endcontent-ref %}
98+
99+
{% content-ref url="assertnotvisible.md" %}
100+
[assertnotvisible.md](assertnotvisible.md)
101+
{% endcontent-ref %}

api-reference/commands/asserttrue.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ You can also use it to immediately fail the test:
3636
{% content-ref url="assertnotvisible.md" %}
3737
[assertnotvisible.md](assertnotvisible.md)
3838
{% endcontent-ref %}
39+
40+
{% content-ref url="assertequal.md" %}
41+
[assertequal.md](assertequal.md)
42+
{% endcontent-ref %}

0 commit comments

Comments
 (0)