Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appium log hangs forever when it gets to Executing Flutter driver command 'click' #181

Closed
liammrharris opened this issue Sep 3, 2021 · 11 comments

Comments

@liammrharris
Copy link

Appium log hangs forever when it gets to Executing Flutter driver command 'click'.

The app launches fine. Then the last two lines I see are:

[debug] [FlutterDriver] Executing Flutter driver command 'click' [debug] [FlutterDriver] >>> {"command":"tap","finderType":"ByValueKey","keyValueString":"contact-button","keyValueType":"String"}

Below is the appium log from the point where flutter driver is first mentioned. I could post the entire log.

Does this mean…

  • the element cannot be found?
  • there’s something wrong with the setup?
  • something else?

At the moment, I am quite clueless as to how to troubleshoot this.

[debug] [FlutterDriver] /Users/liamharris/Library/Android/sdk/platform-tools/adb -s emulator-5554 forward tcp:46427 tcp:46427
[FlutterDriver] Attempt #1
[FlutterDriver] Connecting to Dart Observatory: ws://127.0.0.1:46427/gY6q1iZE0u8=/ws
[FlutterDriver] Connected to ws://127.0.0.1:46427/gY6q1iZE0u8=/ws
[FlutterDriver] Listing all isolates: [{"type":"@Isolate","id":"isolates/1851195815643283","name":"main","number":"1851195815643283","isSystemIsolate":false}]
[FlutterDriver] "ext.flutter.driver" is not found in "extensionRPCs" ["ext.ui.window.scheduleFrame","ext.dart.io.getHttpEnableTimelineLogging","ext.dart.io.setHttpEnableTimelineLogging","ext.dart.io.httpEnableTimelineLogging","ext.dart.io.getSocketProfile","ext.dart.io.startSocketProfiling","ext.dart.io.pauseSocketProfiling","ext.dart.io.socketProfilingEnabled","ext.dart.io.clearSocketProfile","ext.dart.io.getVersion","ext.dart.io.getHttpProfile","ext.dart.io.getHttpProfileRequest","ext.dart.io.clearHttpProfile","ext.flutter.reassemble","ext.flutter.exit","ext.flutter.platformOverride","ext.flutter.brightnessOverride","ext.flutter.connectedVmServiceUri","ext.flutter.activeDevToolsServerAddress","ext.flutter.timeDilation","ext.flutter.evict","ext.flutter.invertOversizedImages","ext.flutter.debugPaint","ext.flutter.debugPaintBaselinesEnabled","ext.flutter.repaintRainbow","ext.flutter.debugCheckElevationsEnabled","ext.flutter.debugDumpLayerTree","ext.flutter.debugDumpRenderTree","ext.flutter.debugDumpSemanticsTreeInTraversalOrder","ext.flutter.debugDumpSemanticsTreeInInverseHitTestOrder","ext.flutter.debugDumpApp","ext.flutter.showPerformanceOverlay","ext.flutter.didSendFirstFrameEvent","ext.flutter.didSendFirstFrameRasterizedEvent","ext.flutter.fastReassemble","ext.flutter.profileWidgetBuilds","ext.flutter.debugAllowBanner","ext.flutter.debugWidgetInspector"]
[FlutterDriver] Waiting 300 seconds before trying...
[FlutterDriver] Attempt #2
[FlutterDriver] Connecting to Dart Observatory: ws://127.0.0.1:46427/gY6q1iZE0u8=/ws
[FlutterDriver] Connected to ws://127.0.0.1:46427/gY6q1iZE0u8=/ws
[FlutterDriver] Listing all isolates: [{"type":"@Isolate","id":"isolates/1851195815643283","name":"main","number":"1851195815643283","isSystemIsolate":false}]
[Appium] New FlutterDriver session created successfully, session e57475b6-a658-4457-bb90-03aa62bed580 added to master session list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1630690650505 (19:37:30 GMT+0200 (Central European Summer Time))
[debug] [MJSONWP (e57475b6)] Cached the protocol value 'MJSONWP' for the new session e57475b6-a658-4457-bb90-03aa62bed580
[debug] [MJSONWP (e57475b6)] Responding to client with driver.createSession() result: {"shell":false,"allowCors":false,"reboot":false,"ipa":null,"address":"0.0.0.0","port":4723,"basePath":"/wd/hub","keepAliveTimeout":null,"callbackAddress":null,"callbackPort":null,"bootstrapPort":4724,"backendRetries":3,"sessionOverride":false,"launch":false,"logFile":null,"loglevel":"debug","logTimestamp":false,"localTimezone":false,"logNoColors":false,"webhook":null,"safari":false,"defaultDevice":false,"forceIphone":false,"forceIpad":false,"automationTraceTemplatePath":null,"instrumentsPath":null,"nodeconfig":null,"robotAddress":"0.0.0.0","robotPort":-1,"chromedriverExecutable":null,"showConfig":false,"noPermsCheck":false,"enforceStrictCaps":false,"isolateSimDevice":false,"tmpDir":"/var/folders/nm/1rsxlpr13h99w167fps7q95m0000gn/T","traceDir":null,"debugLogSpacing":false,"suppressKillServer":false,"longStacktrace":false,"webkitDebugProxyPort":27753,"wdaLocalPort":8100,"defaultCapabilities":{},"relaxedSecurityEnabled":false,"allowInsecure":[],"denyInsecure":[],"defaultCommandTimeout":60,"keepArtifacts":fals...
[HTTP] <-- POST /wd/hub/session 200 321680 ms - 2121
[HTTP] 
[HTTP] --> POST /wd/hub/session/e57475b6-a658-4457-bb90-03aa62bed580/element/eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoiY29udGFjdC1idXR0b24iLCJrZXlWYWx1ZVR5cGUiOiJTdHJpbmcifQ==/click
[HTTP] {"id":"eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoiY29udGFjdC1idXR0b24iLCJrZXlWYWx1ZVR5cGUiOiJTdHJpbmcifQ==","sessionId":"e57475b6-a658-4457-bb90-03aa62bed580"}
[debug] [MJSONWP (e57475b6)] Calling AppiumDriver.click() with args: ["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoiY29udGFjdC1idXR0b24iLCJrZXlWYWx1ZVR5cGUiOiJTdHJpbmcifQ==","e57475b6-a658-4457-bb90-03aa62bed580"]
[debug] [FlutterDriver] Executing Flutter driver command 'click'
[debug] [FlutterDriver] >>> {"command":"tap","finderType":"ByValueKey","keyValueString":"contact-button","keyValueType":"String"}
@ghost
Copy link

ghost commented Sep 22, 2021

I have the exact same issue :/

@KazuCocoa
Copy link
Member

It looks like appium flutter driver was not able to get any responses from the DartVM(Flutter) because the DartVM side got stuck(?). So appium-flutter-driver kept waiting for the response...

@ghost
Copy link

ghost commented Sep 23, 2021

I was actually able to solve this by sending flutter:EnterText via driver.execute_script. After that it would no longer halt on tab

@Smibser
Copy link

Smibser commented Dec 1, 2021

I have the same issue. For me commands like driver.execute('flutter:getTopLeft', finder) are working and even driver.execute('flutter: getRenderTree') returns the correct render tree. So there is a working connection to the flutter app. But if I want to execute driver.execute('flutter:waitFor', finder) or driver.elementClick(finder) it hangs forever as described in that issue.
@KazuCocoa is there a way to resolve the stuck of the DartVm side?

Here is a cutout from the appium server log:

[HTTP] --> POST /wd/hub/session/a35b4885-6f82-45fd-8e51-d0b72c970bb4/execute/sync
[HTTP] {"script":"flutter:getTopLeft","args":["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoiY29udGludWUtYnV0dG9uIiwia2V5VmFsdWVUeXBlIjoiU3RyaW5nIn0"]}
[debug] [W3C (a35b4885)] Calling AppiumDriver.execute() with args: ["flutter:getTopLeft",["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoiY29udGludWUtYnV0dG9uIiwia2V5VmFsdWVUeXBlIjoiU3RyaW5nIn0"],"a35b4885-6f82-45fd-8e51-d0b72c970bb4"]
[debug] [FlutterDriver] Executing Flutter driver command 'execute'
[debug] [FlutterDriver] >>> {"command":"get_offset","finderType":"ByValueKey","keyValueString":"continue-button","keyValueType":"String","offsetType":"topLeft"}
[debug] [FlutterDriver] <<< {"isError":false,"response":{"dx":16,"dy":671.2727272727273},"type":"_extensionType","method":"ext.flutter.driver"} | previous command get_offset
[debug] [W3C (a35b4885)] Responding to client with driver.execute() result: {"dx":16,"dy":671.2727272727273}
[HTTP] <-- POST /wd/hub/session/a35b4885-6f82-45fd-8e51-d0b72c970bb4/execute/sync 200 2365 ms - 42
[HTTP] 
[HTTP] --> POST /wd/hub/session/a35b4885-6f82-45fd-8e51-d0b72c970bb4/execute/sync
[HTTP] {"script":"flutter:waitFor","args":["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoicmVjaXBlLXRpbGUtMC1jaGVja2JveCIsImtleVZhbHVlVHlwZSI6IlN0cmluZyJ9"]}
[debug] [W3C (a35b4885)] Calling AppiumDriver.execute() with args: ["flutter:waitFor",["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoicmVjaXBlLXRpbGUtMC1jaGVja2JveCIsImtleVZhbHVlVHlwZSI6IlN0cmluZyJ9"],"a35b4885-6f82-45fd-8e51-d0b72c970bb4"]
[debug] [FlutterDriver] Executing Flutter driver command 'execute'
[debug] [FlutterDriver] >>> {"command":"waitFor","finderType":"ByValueKey","keyValueString":"recipe-tile-0-checkbox","keyValueType":"String"}

@Smibser
Copy link

Smibser commented Dec 1, 2021

I have the same issue. For me commands like driver.execute('flutter:getTopLeft', finder) are working and even driver.execute('flutter: getRenderTree') returns the correct render tree. So there is a working connection to the flutter app. But if I want to execute driver.execute('flutter:waitFor', finder) or driver.elementClick(finder) it hangs forever as described in that issue. @KazuCocoa is there a way to resolve the stuck of the DartVm side?

Here is a cutout from the appium server log:

[HTTP] --> POST /wd/hub/session/a35b4885-6f82-45fd-8e51-d0b72c970bb4/execute/sync
[HTTP] {"script":"flutter:getTopLeft","args":["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoiY29udGludWUtYnV0dG9uIiwia2V5VmFsdWVUeXBlIjoiU3RyaW5nIn0"]}
[debug] [W3C (a35b4885)] Calling AppiumDriver.execute() with args: ["flutter:getTopLeft",["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoiY29udGludWUtYnV0dG9uIiwia2V5VmFsdWVUeXBlIjoiU3RyaW5nIn0"],"a35b4885-6f82-45fd-8e51-d0b72c970bb4"]
[debug] [FlutterDriver] Executing Flutter driver command 'execute'
[debug] [FlutterDriver] >>> {"command":"get_offset","finderType":"ByValueKey","keyValueString":"continue-button","keyValueType":"String","offsetType":"topLeft"}
[debug] [FlutterDriver] <<< {"isError":false,"response":{"dx":16,"dy":671.2727272727273},"type":"_extensionType","method":"ext.flutter.driver"} | previous command get_offset
[debug] [W3C (a35b4885)] Responding to client with driver.execute() result: {"dx":16,"dy":671.2727272727273}
[HTTP] <-- POST /wd/hub/session/a35b4885-6f82-45fd-8e51-d0b72c970bb4/execute/sync 200 2365 ms - 42
[HTTP] 
[HTTP] --> POST /wd/hub/session/a35b4885-6f82-45fd-8e51-d0b72c970bb4/execute/sync
[HTTP] {"script":"flutter:waitFor","args":["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoicmVjaXBlLXRpbGUtMC1jaGVja2JveCIsImtleVZhbHVlVHlwZSI6IlN0cmluZyJ9"]}
[debug] [W3C (a35b4885)] Calling AppiumDriver.execute() with args: ["flutter:waitFor",["eyJmaW5kZXJUeXBlIjoiQnlWYWx1ZUtleSIsImtleVZhbHVlU3RyaW5nIjoicmVjaXBlLXRpbGUtMC1jaGVja2JveCIsImtleVZhbHVlVHlwZSI6IlN0cmluZyJ9"],"a35b4885-6f82-45fd-8e51-d0b72c970bb4"]
[debug] [FlutterDriver] Executing Flutter driver command 'execute'
[debug] [FlutterDriver] >>> {"command":"waitFor","finderType":"ByValueKey","keyValueString":"recipe-tile-0-checkbox","keyValueType":"String"}

I just found out that if I use byText as finder I can click an element. But I am sure that the value key is correct because I checked it in the render tree.

@KazuCocoa
Copy link
Member

I have no good idea, sorry.
Afaik, this flutter driver simply calls https://api.flutter.dev/flutter/flutter_driver/flutter_driver-library.html commands to the DartVM. How to handle them depends on the Flutter implementation.
So, possibly it is only flutter team can improve the behavior.

@vbhvkthr1
Copy link

vbhvkthr1 commented Sep 19, 2022

I was actually able to solve this by sending flutter:EnterText via driver.execute_script. After that it would no longer halt on tab

Hi - in my case test is stuck at click on elemenet itself so cannot reach flutter:entertext step. How did you manage to focus on element before flutter:enterText? Appium server logs below where it stuck

[HTTP] {"id":"eyJrZXlWYWx1ZVR5cGUiOiJTdHJpbmciLCJrZXlWYWx1ZVN0cmluZyI6ImtleV90ZXh0X2ZpZWxkX290cCIsImZpbmRlclR5cGUiOiJCeVZhbHVlS2V5In0="}
[debug] [FlutterDriver@7859 (6898abbe)] Calling AppiumDriver.click() with args: ["eyJrZXlWYWx1ZVR5cGUiOiJTdHJpbmciLCJrZXlWYWx1ZVN0cmluZyI6ImtleV90ZXh0X2ZpZWxkX290cCIsImZpbmRlclR5cGUiOiJCeVZhbHVlS2V5In0=","6898abbe-d32e-4c5d-a607-1a14aafbde25"]
[debug] [FlutterDriver] Executing Flutter driver command 'click'
[debug] [FlutterDriver] >>> {"command":"tap","keyValueType":"String","keyValueString":"key_text_field_otp","finderType":"ByValueKey"}

@ghost
Copy link

ghost commented Oct 6, 2022

@vbhvkthr1
Actually, the workaround consists in:

Instead of using it:
await driver.elementClick(find.byValueKey('AC_BUTTON'));

Use it:
await driver.elementClick(find.byText('AC'));

It is a workaround, but It is not a good practice to use text attribute to find elements.

@KazuCocoa
Copy link
Member

This behavior seems to be coming inside DartVM/Flutter. Close as not in this driver itself.

@ghost
Copy link

ghost commented Nov 22, 2022

I solved this problem and identified the root cause.

By default, Flutter Driver waits until there is no pending frame scheduled in the app under test before executing an action. Because of this, some interactions such as click() may not work properly. To counter it, we use setFrameSync() function before and after the desired action.

So with that, the code would be:

    def tap_element(self, element: Element):
        self.driver.execute_script('flutter:setFrameSync', True, 5000)
        self.find(element).click()
        self.driver.execute_script('flutter:setFrameSync', False, 5000)

@Amirtha-cp
Copy link

@liammrharris liammrharris c was this resolved? can you please share the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants