tapOn with Regex taps on the wrong item
Is there an existing issue for this?
- [x] I have searched the existing issues and didn't find mine.
Steps to reproduce
The minimal repro can be either downloaded here (.app built for the simulator, just extract the tar and drag it into an iOS simulator), or it can be built with the following steps:
- Clone the repo at https://github.com/yolpsoftware/maestro-bugtest (branch master)
- Open a terminal inside it and run npm install
- Then npx expo run:ios --device, this will create a build for the simulator
- When it asks on which simulator device you want to run it, choose one, don't choose an actual device.
- If it asks for a development account, provide one.
Then, start Maestro Studio. The bug is reproducible in Maestro Studio, but it is also happening when testing with Maestro.
Actual results
We want to click on the first item in the list:
Maestro Studio tells me that I can do that with
tapOn: Capisce? - Do you understand? 🇮🇹 Italian Words not yet
This works great, and it confirms that the UI should be okay for Maestro.
However, when I replace the last word by a .* regular expression, the whole thing stops working:
tapOn: Capisce? - Do you understand? 🇮🇹 Italian Words not .*
So I thought, maybe Maestro now considers this to be a Regex - which makes the question marks behave differently. That would make sense. So I replaced them by
tapOn: Capisce\? - Do you understand\? 🇮🇹 Italian Words not .*
or
tapOn: Capisce. - Do you understand. 🇮🇹 Italian Words not .*
But now Maestro taps on one of the "dummy" elements, even though there is no matching text there.
Expected results
Maestro should tap on the element with matching text.
Also, from the docs it's not clear when Maestro is using a regex and when not.
About app
This is a React Native app using Expo. It uses the latest frameworks:
"expo": "~52.0.46",
"react-native": "0.76.9",
About environment
Apple M4 Pro (arm64), Macbook Pro, macOS Sequoia 15.4.1.
openjdk version "21.0.7" 2025-04-15 LTS
OpenJDK Runtime Environment Temurin-21.0.7+6 (build 21.0.7+6-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.7+6 (build 21.0.7+6-LTS, mixed mode, sharing)
Logs
Logs
this is done entirely in Maestro Studio, so no logs here
Maestro version
1.40.0
How did you install Maestro?
install script (https://get.maestro.mobile.dev)
Anything else?
No response
At a guess, the container around the list contains accessibilityText containing the text of all of the elements within it. The reason you get a Dummy is because it's in the middle of the container.
Could this be the case? Is this something I can help you debug?
Well, for a start, it might be really useful if the docs were clear about when Regular Expressions were used and when not. Maestro Studio tells me to use this:
tapOn: Capisce? - Do you understand? 🇮🇹 Italian Words not yet
But that's clearly not meant as a Regex due to the ?. Sometimes it's using Regex, sometimes not.
I will have a look at this again next week, would be great to debug this together!
Some nerdy detail: Maestro will match when interpreting your input as either plain or regex. So it's always using both.
Example:
- assertVisible: 'Chip.'
This will match against Chip. and against Chips (since . is 'any 1 character')
Did you look at my idea about whether the accessibilityText was getting concatenated into the container?
Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a minimal, reproducible sample. When creating a new issue, please make sure to diligently fill out the issue template.
Thank you for your contribution to our open-source community!
Sorry Dan, I have to find time to look into this again, but I will.