mobile-dev-inc / maestro

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

[v1.36.0] Got Error: Unable to establish a connection to the XCUITest server #1802

Open yobelioekaharja opened 1 month ago

yobelioekaharja commented 1 month ago

Describe the bug I tried to run my test in iOS using maestro. The flow is:

  1. Open a deeplink
  2. Assert the page opened successfully
  3. Tap on some menu
  4. Swipe the screen 3 times
  5. Assert some section displayed
  6. etc...

I got 2 problems here:

  1. After run the maestro test flow.yaml (flow.yaml is my yaml file for the iOS flow), I experience slowness on iOS to start the test. It seems that maestro tried to reinstall its maestro-driver and sometimes not successfully. I used to kill my simulator, reopen the simulator, and run the test again. Then the maestro-driver can installed properly. Nevertheless, to start the first step of my test (opening the deeplink) still takes long time
  2. When the maestro start my test flow, at some point, it got error log (attached in the picture below). This error log comes randomly. Sometimes it comes when the code try to tap menu, sometimes it comes when the code try to swap the screen. The error Retrying connection to the XCUITest server for... happened but didn't make my test failed at all. After I wait for a while, my test can successfully continue to run the next steps. But, this error log comes again and again. This makes my test takes very long time to run and not finished yet until I kill my terminal who run the maestro test. Even after the test successfully continue after got the Retrying connection..., but in the end my test still cannot run successfully until the end flow. Even though the error said that Unable to establish a connection to the XCUITest server... and because of XCUITest server got crashed/exit..., but I am sure that my internet connection is still connected, the simulator not hang, and my app also still opened.

To Reproduce Steps to reproduce the behavior:

  1. Start the simulator
  2. Run maestro test flow.yaml
  3. The Flow fails in the middle of my test

Expected behavior The expected behavior is maestro can successfully execute my command like tapOn, swipe, etc. Besides that, my test should can finished successfully. Either it will passed or failed.

Screenshots

Screenshot 2024-07-15 at 17 08 23

Environment information (please complete the following information):

Additional context For additional context: I run my test case with a good internet connection. The apps also opened successfully. The simulator still running and not hang.

bartekpacia commented 1 month ago

Hi, thanks for taking time to create this detailed issue, and sorry about the problem.

Could you please share the flow and app binary? otherwise it's hard to debug.

yobelioekaharja commented 1 month ago

Sorry, I cannot share the app because it is my company's internal app. Update for this case: Previously I use Xcode 13.3 and got this issue. Then I upgraded mine into Xcode 15.3, this issue still happened. But somehow I managed to solve this by following this guide. Nevertheless, I still curious and don't know why there are some unfinished iOS driver maestro process. In summary, killing all the unfinished process can help me

Additional info: I also ask my friend to try this case. He use the same simulator, but use different Xcode version (still using Xcode 13.3). Even after killing all unfinished process, the issue still replicable for him (with Xcode 13.3).

emmaarnott commented 1 month ago

I am also having this issue - I am running Xcode 16 beta 3, I see maestro-driver-iosUITests-Runner quit unexpectedly. I've included details and attached screenshots and logs.

Maestro version: 1.36.0 Platform: Xcode 16 beta 3 Framework: iOS Device model and OS version: iPhone 15 Pro, iOS 17.5 Simulator, emulator or physical device: Simulator Host [e.g. Mac M1, Windows, Linux, etc]: Mac M2, Sonoma 14.5

CleanShot 2024-07-17 at 11 01 55@2x

maestro.txt

emmaarnott commented 1 month ago

I am also having this issue - I am running Xcode 16 beta 3, I see maestro-driver-iosUITests-Runner quit unexpectedly. I've included details and attached screenshots and logs.

Maestro version: 1.36.0 Platform: Xcode 16 beta 3 Framework: iOS Device model and OS version: iPhone 15 Pro, iOS 17.5 Simulator, emulator or physical device: Simulator Host [e.g. Mac M1, Windows, Linux, etc]: Mac M2, Sonoma 14.5

CleanShot 2024-07-17 at 11 01 55@2x

maestro.txt

I am not sure if this is helpful, but thought to mention that I have realized that this only happens to me when I try to run a test that involves inputting text. All other tests that just involve taps, scroll etc work fine.

CleanShot 2024-07-29 at 17 08 58@2x

yobelioekaharja commented 1 month ago

Have you already tried to kill all maestro process before run your test? @emmaarnott pgrep -lf maestro | awk '{print $1}' | xargs -r kill

emmaarnott commented 1 month ago

@yobelioekaharja Yeah, I have tried killing all maestro processes then running the test again but it does not help.

DavidREntwistle commented 1 month ago

This is also an issue on the latest 1.37.4 CLI

andreped commented 3 weeks ago

I am not sure if this is helpful, but thought to mention that I have realized that this only happens to me when I try to run a test that involves inputting text. All other tests that just involve taps, scroll etc work fine.

THANK YOU, @emmaarnott! This was extremely helpful for me! Finally I can go to bed...

Omfg, I spent two days on this, just to find that inputText was broken, as well as timeout needed to be increased.

At least I am able to do very simple e2e tests through GitHub Actions now.

Have you found a workaround to get inputText working?

emmaarnott commented 2 weeks ago

I am not sure if this is helpful, but thought to mention that I have realized that this only happens to me when I try to run a test that involves inputting text. All other tests that just involve taps, scroll etc work fine.

THANK YOU, @emmaarnott! This was extremely helpful for me! Finally I can go to bed...

Omfg, I spent two days on this, just to find that inputText was broken, as well as timeout needed to be increased.

At least I am able to do very simple e2e tests through GitHub Actions now.

Have you found a workaround to get inputText working?

@andreped Oh, I am so glad to hear that it helped you from going completely insane, I know that feeling all too well 😅 Tbh I didn't try to figure out a workaround as our tests aren't urgent right now, but I just tried to run my test that has inputText in it again, and it works now - so appears to be fixed in the most recent version of maestro?

andreped commented 2 weeks ago

@andreped Oh, I am so glad to hear that it helped you from going completely insane, I know that feeling all too well 😅 Tbh I didn't try to figure out a workaround as our tests aren't urgent right now, but I just tried to run my test that has inputText in it again, and it works now - so appears to be fixed in the most recent version of maestro?

@emmaarnott That is interesting! Did you upgrade Maestro in GitHub Actions to latest, or how did it resolve itself? :P

I mean I can run my CI again to see if it is fixed, but we use a fixed version of Maestro in our CIs.

emmaarnott commented 2 weeks ago

@andreped Oh, I am so glad to hear that it helped you from going completely insane, I know that feeling all too well 😅 Tbh I didn't try to figure out a workaround as our tests aren't urgent right now, but I just tried to run my test that has inputText in it again, and it works now - so appears to be fixed in the most recent version of maestro?

@emmaarnott That is interesting! Did you upgrade Maestro in GitHub Actions to latest, or how did it resolve itself? :P

I mean I can run my CI again to see if it is fixed, but we use a fixed version of Maestro in our CIs.

@andreped Ah OK - nope, I just updated via terminal this morning by running curl -Ls "https://get.maestro.mobile.dev" | bash So ran that test on version 1.37.9 of the CLI and it's working for me. In saying that, this is the first time I've tried since I initially commented when I was using v1.36.0. We don't use GitHub Actions, we just run the scripts from terminal

andreped commented 2 weeks ago

@andreped Ah OK - nope, I just updated via terminal this morning by running curl -Ls "https://get.maestro.mobile.dev" | bash So ran that test on version 1.37.9 of the CLI and it's working for me. In saying that, this is the first time I've tried since I initially commented when I was using v1.36.0. We don't use GitHub Actions, we just run the scripts from terminal

Oh, I see. No, in my case I am seeing this on headless servers (github actions) when I am trying to run tests with maestro.

All works fine for me locally, at least on my macbook with M2 chip - at least with the later versions.

emmaarnott commented 2 weeks ago

@andreped Ah OK - nope, I just updated via terminal this morning by running curl -Ls "https://get.maestro.mobile.dev" | bash So ran that test on version 1.37.9 of the CLI and it's working for me. In saying that, this is the first time I've tried since I initially commented when I was using v1.36.0. We don't use GitHub Actions, we just run the scripts from terminal

Oh, I see. No, in my case I am seeing this on headless servers (github actions) when I am trying to run tests with maestro.

All works fine for me locally, at least on my macbook with M2 chip - at least with the later versions.

ah, shame :(

Lenovis commented 2 weeks ago

I think I'm facing the same issue when trying to use Maestro to interact with the inputText field during an Expo EAS Build. Everything works perfectly when running Maestro locally, but when I run the same setup in EAS Build, the interaction with the input field fails with an error, as shown in the screenshot below:

image

EAS Build Environment: Version 1.37.9 of Maestro is being installed automatically during the build process.

Running locally, everything works fine, but when I try to do it in EAS, this issue happens.