maestro icon indicating copy to clipboard operation
maestro copied to clipboard

[1.34.0] Tapping on YES or NO labels does not work

Open fantpmas opened this issue 1 year ago • 6 comments

Describe the bug Tapping on YES or NO labels does not work.

To Reproduce

  1. Have dialogue with YES or NO labels
  2. -tapOn: YES

Expected behavior YES option is tapped.

Screenshots Screenshot 2023-11-06 at 14 39 23 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$

fantpmas avatar Nov 06 '23 13:11 fantpmas

At least myself and one other person have encountered this bug, according to the Maestro Slack.

meatnordrink avatar Nov 06 '23 15:11 meatnordrink

@fantpmas can you provide the screen view hierarchy? Run maestro hierarchy and paste the output

felipevolpone avatar Nov 27 '23 12:11 felipevolpone

Here you go: hierarchy.txt

fantpmas avatar Nov 29 '23 08:11 fantpmas

Does the same happen when running with maestro test testing.yaml ?

felipevolpone avatar Feb 21 '24 14:02 felipevolpone

Yes, the issue is pretty clear if you look at the logs: Screenshot 2024-02-22 at 15 48 00

This works fine by the way:

- tapOn:
    text: 'YES'

fantpmas avatar Feb 22 '24 14:02 fantpmas

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

felipevolpone avatar Feb 22 '24 16:02 felipevolpone

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

bartekpacia avatar Jul 12 '24 22:07 bartekpacia