Detect Maestro in your app
Last updated
Was this helpful?
Last updated
Was this helpful?
The recommended way to check if maestro is currently running is to use and have your app detect a particular parameter to indicate Maestro's usage, e.g. isE2ETest
.
Using ports is deprecated and may stop working at any time in future maestro updates and is not supported when .
It's sometimes useful to be able to add logic in your app that depends that whether you are running within the context of Maestro. In order to detect Maestro, check to see whether the Maestro-specific port is open on your device:
iOS
22087
Android
7001
Here's an example of how to check for Maestro in an Android app:
On Android, you may encounter a NetworkOnMainThreadException
. This means you'll need to move the call above to a background thread. As an example: