mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.36k stars 248 forks source link

[Feature Request] - Compose Multiplatform #1549

Open GuilhE opened 8 months ago

GuilhE commented 8 months ago

Is your feature request related to a problem? Please describe. Adding support for Compose Multiplatform would be a valuable enhancement, especially considering JetBrains's significant investment in it.

Describe the solution you'd like Same functionality we have when using Jetpack Compose and Swift UI:

Additional context You can test it by running my sample and compare the time it takes to evaluate for instance:

using Maestro Studio on Swift UI and Compose screen with an iOS Simulator. I'm also experiencing random crashs when navigating between screens when Maestro Studio is connected with the iOS Simulator:

Navigate to http://localhost:9999 in your browser to open Maestro Studio. Ctrl-C to exit.
io.ktor.util.cio.ChannelWriteException: Cannot write to a channel
        at io.ktor.server.netty.cio.NettyHttpResponsePipeline.respondWithFailure(NettyHttpResponsePipeline.kt:102)
        at io.ktor.server.netty.cio.NettyHttpResponsePipeline.respondWithBodyAndTrailerMessage(NettyHttpResponsePipeline.kt:252)
        at io.ktor.server.netty.cio.NettyHttpResponsePipeline.access$respondWithBodyAndTrailerMessage(NettyHttpResponsePipeline.kt:26)
        at io.ktor.server.netty.cio.NettyHttpResponsePipeline$respondWithBodyAndTrailerMessage$1.invokeSuspend(NettyHttpResponsePipeline.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.ktor.server.netty.EventLoopGroupProxy$Companion.create$lambda$1$lambda$0(NettyApplicationEngine.kt:291)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.netty.channel.StacklessClosedChannelException
        at io.netty.channel.AbstractChannel$AbstractUnsafe.write(Object, ChannelPromise)(Unknown Source)
        Error: Request for viewHierarchy failed, because of app crash, body: {"errorMessage":"Error getting main window kAXErrorCannotComplete","code":"internal"}
maestro.MaestroException$AppCrash: App crashed or stopped while executing flow, please check diagnostic logs: ~/Library/Logs/DiagnosticReports directory
        at maestro.drivers.IOSDriver.runDeviceCall(IOSDriver.kt:482)
        at maestro.drivers.IOSDriver.contentDescriptor(IOSDriver.kt:142)
        at maestro.ViewHierarchy$Companion.from-c1iYVAs(ViewHierarchy.kt:29)
        at maestro.Maestro.viewHierarchy-prqvCes(Maestro.kt:405)
        at maestro.studio.DeviceService.getDeviceScreen(DeviceService.kt:172)
        at maestro.studio.DeviceService.access$getDeviceScreen(DeviceService.kt:43)
        at maestro.studio.DeviceService$routes$3$1.invokeSuspend(DeviceService.kt:82)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

To replicate:

  1. Tap on COMPOSE
  2. Tap on Back
  3. repeat until it crashes

When the Maestro Studio is not connected it will not crash.

Alaksion commented 1 month ago

@GuilhE Have you managed to get maestro test working on IOS devices? I'm trying to write a workflow to run my CMP app on IOS but it looks like the composition content is not accessible

Alaksion commented 1 month ago

Looks like the accessibility indexes can be interacted with when accessibilitySyncOptions is set to Always inside the MainViewController composable. But even then I cannot interact with the elements using actions