maestro
maestro copied to clipboard
[1.34.0] Tapping on YES or NO labels does not work
Describe the bug Tapping on YES or NO labels does not work.
To Reproduce
- Have dialogue with YES or NO labels
-
-tapOn: YES
Expected behavior YES option is tapped.
Screenshots
Maestro Studio shows success, but button is not tapped.
Environment information (please complete the following information):
- Maestro version 1.34.0
- Platform: Android
- Framework: React Native
Additional context This does work:
tapOn:
text: ^YES$
At least myself and one other person have encountered this bug, according to the Maestro Slack.
@fantpmas can you provide the screen view hierarchy? Run maestro hierarchy
and paste the output
Here you go: hierarchy.txt
Does the same happen when running with maestro test testing.yaml
?
Yes, the issue is pretty clear if you look at the logs:
This works fine by the way:
- tapOn:
text: 'YES'
Oh if it works with quotes it seems a bug in the process of converting the yaml to maestro object, I'd guess that it's converting YES
to boolean instead of string
Yeah, it's a problem with YAML[^1]. YES
, yes
are aliases for true
. NO
, no
are aliases for false
. This is working as intended.
I'm afraid there's not much we can do apart from updating the docs to encourage users to use double quotes.
Below is a repro:
Flutter app example code
Paste into main.dart
and flutter run
.
import 'package:flutter/material.dart';
class ExampleApp extends StatefulWidget {
const ExampleApp({super.key});
@override
State<ExampleApp> createState() => _ExampleAppState();
}
class _ExampleAppState extends State<ExampleApp> {
int count = 0;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('demo')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Count $count'),
const Text('YES/yes to increase, NO/no to decrease'),
TextButton(
onPressed: () {
setState(() => count++);
},
child: const Text('YES'),
),
TextButton(
onPressed: () {
setState(() => count++);
},
child: const Text('yes'),
),
TextButton(
onPressed: () {
setState(() => count--);
},
child: const Text('NO'),
),
TextButton(
onPressed: () {
setState(() => count--);
},
child: const Text('no'),
),
],
),
),
),
);
}
}
Successful flow example
appId: com.example.example
---
- launchApp
- tapOn: "YES"
- tapOn: "yes"
- assertVisible: Count 2
- tapOn: "NO"
- tapOn: "no"
- assertVisible: Count 0
Running on emulator-5554
║
║ > Flow
║
║ ✅ Launch app "com.example.example"
║ ✅ Tap on "YES"
║ ✅ Tap on "yes"
║ ✅ Assert that "Count 2" is visible
║ ✅ Tap on "NO"
║ ✅ Tap on "no"
║ ✅ Assert that "Count 0" is visible
║
Failing flow example
appId: com.example.example
---
- launchApp
- tapOn: YES
- tapOn: yes
- assertVisible: Count 2
- tapOn: NO
- tapOn: no
- assertVisible: Count 0
Running on emulator-5554
║
║ > Flow
║
║ ✅ Launch app "com.example.example"
║ ❌ Tap on "true"
║ 🔲 Tap on "true"
║ 🔲 Assert that "Count 2" is visible
║ 🔲 Tap on "false"
║ 🔲 Tap on "false"
║ 🔲 Assert that "Count 0" is visible
║
[^1]: A fun read: https://noyaml.com