Detect Maestro in your App

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:

PlatformMaestro Port on Device





Here's an example of how to check for Maestro in an Android app:

fun isMaestro(): Boolean {
    return try {
        Socket("localhost", 7001).use { true }
    } catch(ignored: IOException) {

An alternative is to use arguments and have your app detect a particular parameter to indicate Maestro's usage, e.g. isE2ETest.

Last updated