Skip to content

inTest assertion errors and async leaks when using Appium Flutter Integration Driver #132

@munish-singleops

Description

@munish-singleops

🐛 Bug Report

We are facing random test failures while running Flutter integration tests through Appium + appium-flutter-integration-driver.
The error consistently points to Flutter’s WidgetTester APIs being called outside a valid test context, causing:

  • "inTest: is not true" assertion failures
  • "Asynchronous call to guarded function leaked. You must use 'await' with all Future-returning test APIs."
  • Retrying loops in Appium but eventually failing

Error 1:

issue 1: [0-0] [2025-08-26T17:16:52.397Z] DEBUG: Entering Text: ipsa into Element [0-0] [2025-08-26T17:16:55.090Z] DEBUG: Initial send keys failed with error: unknown error: WebDriverError: An unknown server-side error occurred while processing the command. Original error: Asynchronous call to guarded function leaked. [0-0] You must use "await" with all Future-returning test APIs. [0-0] The test API method "pump" from class WidgetTester was called from dart:async/zone.dart on line 1414, but never completed before its parent scope closed. [0-0] An uncaught exception may have caused the guarded function leak. The exception was: [0-0] 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true. [0-0] The stack trace associated with this exception was: [0-0] #2 LiveTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1987:12) [0-0] #3 WidgetTester.pump.<anonymous closure> (package:flutter_test/src/widget_tester.dart:667:53) [0-0] #6 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #7 WidgetTester.pump (package:flutter_test/src/widget_tester.dart:667:27) [0-0] #8 WidgetTester.showKeyboard.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1139:13) [0-0] #11 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #12 WidgetTester.showKeyboard (package:flutter_test/src/widget_tester.dart:1127:27) [0-0] #13 WidgetTester.enterText.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1163:13) [0-0] #16 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #17 WidgetTester.enterText (package:flutter_test/src/widget_tester.dart:1162:27) [0-0] #18 ElementHelper.setText (package:appium_flutter_server/src/utils/element_helper.dart:73:18) [0-0] #19 ClearHandler.handle (package:appium_flutter_server/src/handler/clear.dart:21:25) [0-0] <asynchronous suspension> [0-0] #20 RequestHandler.getHandler.<anonymous closure> (package:appium_flutter_server/src/handler/request/request_handler.dart:30:35) [0-0] <asynchronous suspension> [0-0] #21 _RouterPlusHandler._handler (package:shelf_plus/src/router_plus/router_plus.dart:64:16) [0-0] <asynchronous suspension> [0-0] #22 RouterEntry.invoke.<anonymous closure> (package:shelf_router/src/router_entry.dart:107:16) [0-0] <asynchronous suspension> [0-0] #23 RouterEntry.invoke (package:shelf_router/src/router_entry.dart:104:12) [0-0] <asynchronous suspension> [0-0] #24 Router.call (package:shelf_router/src/router.dart:184:26) [0-0] <asynchronous suspension> [0-0] #25 handleRequest (package:shelf/shelf_io.dart:140:16) [0-0] <asynchronous suspension> [0-0] (elided 8 frames from class _AssertionError and dart:async) when running "element/35d08b1c-35d0-8b1c-35d0-8b1c35d08b1c/clear" with method "POST", retrying... [0-0] [2025-08-26T17:16:55.090Z] DEBUG: Retrying function [0-0] [2025-08-26T17:16:57.728Z] DEBUG: Error on attempt 1: unknown error: WebDriverError: An unknown server-side error occurred while processing the command. Original error: Asynchronous call to guarded function leaked. [0-0] You must use "await" with all Future-returning test APIs. [0-0] The test API method "pump" from class WidgetTester was called from dart:async/zone.dart on line 1414, but never completed before its parent scope closed. [0-0] An uncaught exception may have caused the guarded function leak. The exception was: [0-0] 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true. [0-0] The stack trace associated with this exception was: [0-0] #2 LiveTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1987:12) [0-0] #3 WidgetTester.pump.<anonymous closure> (package:flutter_test/src/widget_tester.dart:667:53) [0-0] #6 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #7 WidgetTester.pump (package:flutter_test/src/widget_tester.dart:667:27) [0-0] #8 WidgetTester.showKeyboard.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1139:13) [0-0] #11 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #12 WidgetTester.showKeyboard (package:flutter_test/src/widget_tester.dart:1127:27) [0-0] #13 WidgetTester.enterText.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1163:13) [0-0] #16 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #17 WidgetTester.enterText (package:flutter_test/src/widget_tester.dart:1162:27) [0-0] #18 ElementHelper.setText (package:appium_flutter_server/src/utils/element_helper.dart:73:18) [0-0] #19 ClearHandler.handle (package:appium_flutter_server/src/handler/clear.dart:21:25) [0-0] <asynchronous suspension> [0-0] #20 RequestHandler.getHandler.<anonymous closure> (package:appium_flutter_server/src/handler/request/request_handler.dart:30:35) [0-0] <asynchronous suspension> [0-0] #21 _RouterPlusHandler._handler (package:shelf_plus/src/router_plus/router_plus.dart:64:16) [0-0] <asynchronous suspension> [0-0] #22 RouterEntry.invoke.<anonymous closure> (package:shelf_router/src/router_entry.dart:107:16) [0-0] <asynchronous suspension> [0-0] #23 RouterEntry.invoke (package:shelf_router/src/router_entry.dart:104:12) [0-0] <asynchronous suspension> [0-0] #24 Router.call (package:shelf_router/src/router.dart:184:26) [0-0] <asynchronous suspension> [0-0] #25 handleRequest (package:shelf/shelf_io.dart:140:16) [0-0] <asynchronous suspension> [0-0] (elided 8 frames from class _AssertionError and dart:async) when running "element/35d08b1c-35d0-8b1c-35d0-8b1c35d08b1c/clear" with method "POST" [0-0] [2025-08-26T17:16:58.730Z] DEBUG: Retrying function [0-0] [2025-08-26T17:17:01.387Z] DEBUG: Error on attempt 2: unknown error: WebDriverError: An unknown server-side error occurred while processing the command. Original error: Asynchronous call to guarded function leaked. [0-0] You must use "await" with all Future-returning test APIs. [0-0] The test API method "pump" from class WidgetTester was called from dart:async/zone.dart on line 1414, but never completed before its parent scope closed. [0-0] An uncaught exception may have caused the guarded function leak. The exception was: [0-0] 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true. [0-0] The stack trace associated with this exception was: [0-0] #2 LiveTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1987:12) [0-0] #3 WidgetTester.pump.<anonymous closure> (package:flutter_test/src/widget_tester.dart:667:53) [0-0] #6 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #7 WidgetTester.pump (package:flutter_test/src/widget_tester.dart:667:27) [0-0] #8 WidgetTester.showKeyboard.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1139:13) [0-0] #11 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #12 WidgetTester.showKeyboard (package:flutter_test/src/widget_tester.dart:1127:27) [0-0] #13 WidgetTester.enterText.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1163:13) [0-0] #16 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #17 WidgetTester.enterText (package:flutter_test/src/widget_tester.dart:1162:27) [0-0] #18 ElementHelper.setText (package:appium_flutter_server/src/utils/element_helper.dart:73:18) [0-0] #19 ClearHandler.handle (package:appium_flutter_server/src/handler/clear.dart:21:25) [0-0] <asynchronous suspension> [0-0] #20 RequestHandler.getHandler.<anonymous closure> (package:appium_flutter_server/src/handler/request/request_handler.dart:30:35) [0-0] <asynchronous suspension> [0-0] #21 _RouterPlusHandler._handler (package:shelf_plus/src/router_plus/router_plus.dart:64:16) [0-0] <asynchronous suspension> [0-0] #22 RouterEntry.invoke.<anonymous closure> (package:shelf_router/src/router_entry.dart:107:16) [0-0] <asynchronous suspension> [0-0] #23 RouterEntry.invoke (package:shelf_router/src/router_entry.dart:104:12) [0-0] <asynchronous suspension> [0-0] #24 Router.call (package:shelf_router/src/router.dart:184:26) [0-0] <asynchronous suspension> [0-0] #25 handleRequest (package:shelf/shelf_io.dart:140:16) [0-0] <asynchronous suspension> [0-0] (elided 8 frames from class _AssertionError and dart:async) when running "element/35d08b1c-35d0-8b1c-35d0-8b1c35d08b1c/clear" with method "POST" [0-0] [2025-08-26T17:17:02.388Z] DEBUG: Retrying function [0-0] [2025-08-26T17:17:05.041Z] DEBUG: Error on attempt 3: unknown error: WebDriverError: An unknown server-side error occurred while processing the command. Original error: Asynchronous call to guarded function leaked. [0-0] You must use "await" with all Future-returning test APIs. [0-0] The test API method "pump" from class WidgetTester was called from dart:async/zone.dart on line 1414, but never completed before its parent scope closed. [0-0] An uncaught exception may have caused the guarded function leak. The exception was: [0-0] 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true. [0-0] The stack trace associated with this exception was: [0-0] #2 LiveTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1987:12) [0-0] #3 WidgetTester.pump.<anonymous closure> (package:flutter_test/src/widget_tester.dart:667:53) [0-0] #6 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #7 WidgetTester.pump (package:flutter_test/src/widget_tester.dart:667:27) [0-0] #8 WidgetTester.showKeyboard.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1139:13) [0-0] #11 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #12 WidgetTester.showKeyboard (package:flutter_test/src/widget_tester.dart:1127:27) [0-0] #13 WidgetTester.enterText.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1163:13) [0-0] #16 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #17 WidgetTester.enterText (package:flutter_test/src/widget_tester.dart:1162:27) [0-0] #18 ElementHelper.setText (package:appium_flutter_server/src/utils/element_helper.dart:73:18) [0-0] #19 ClearHandler.handle (package:appium_flutter_server/src/handler/clear.dart:21:25) [0-0] <asynchronous suspension> [0-0] #20 RequestHandler.getHandler.<anonymous closure> (package:appium_flutter_server/src/handler/request/request_handler.dart:30:35) [0-0] <asynchronous suspension> [0-0] #21 _RouterPlusHandler._handler (package:shelf_plus/src/router_plus/router_plus.dart:64:16) [0-0] <asynchronous suspension> [0-0] #22 RouterEntry.invoke.<anonymous closure> (package:shelf_router/src/router_entry.dart:107:16) [0-0] <asynchronous suspension> [0-0] #23 RouterEntry.invoke (package:shelf_router/src/router_entry.dart:104:12) [0-0] <asynchronous suspension> [0-0] #24 Router.call (package:shelf_router/src/router.dart:184:26) [0-0] <asynchronous suspension> [0-0] #25 handleRequest (package:shelf/shelf_io.dart:140:16) [0-0] <asynchronous suspension> [0-0] (elided 8 frames from class _AssertionError and dart:async) when running "element/35d08b1c-35d0-8b1c-35d0-8b1c35d08b1c/clear" with method "POST" [0-0] [2025-08-26T17:17:05.097Z] ERROR: Error: WebDriverError: An unknown server-side error occurred while processing the command. Original error: Asynchronous call to guarded function leaked. [0-0] You must use "await" with all Future-returning test APIs. [0-0] The test API method "pump" from class WidgetTester was called from dart:async/zone.dart on line 1414, but never completed before its parent scope closed. [0-0] An uncaught exception may have caused the guarded function leak. The exception was: [0-0] 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true. [0-0] The stack trace associated with this exception was: [0-0] #2 LiveTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1987:12) [0-0] #3 WidgetTester.pump.<anonymous closure> (package:flutter_test/src/widget_tester.dart:667:53) [0-0] #6 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #7 WidgetTester.pump (package:flutter_test/src/widget_tester.dart:667:27) [0-0] #8 WidgetTester.showKeyboard.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1139:13) [0-0] #11 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #12 WidgetTester.showKeyboard (package:flutter_test/src/widget_tester.dart:1127:27) [0-0] #13 WidgetTester.enterText.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1163:13) [0-0] #16 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) [0-0] #17 WidgetTester.enterText (package:flutter_test/src/widget_tester.dart:1162:27) [0-0] #18 ElementHelper.setText (package:appium_flutter_server/src/utils/element_helper.dart:73:18) [0-0] #19 ClearHandler.handle (package:appium_flutter_server/src/handler/clear.dart:21:25) [0-0] <asynchronous suspension> [0-0] #20 RequestHandler.getHandler.<anonymous closure> (package:appium_flutter_server/src/handler/request/request_handler.dart:30:35) [0-0] <asynchronous suspension> [0-0] #21 _RouterPlusHandler._handler (package:shelf_plus/src/router_plus/router_plus.dart:64:16) [0-0] <asynchronous suspension> [0-0] #22 RouterEntry.invoke.<anonymous closure> (package:shelf_router/src/router_entry.dart:107:16) [0-0] <asynchronous suspension> [0-0] #23 RouterEntry.invoke (package:shelf_router/src/router_entry.dart:104:12) [0-0] <asynchronous suspension> [0-0] #24 Router.call (package:shelf_router/src/router.dart:184:26) [0-0] <asynchronous suspension> [0-0] #25 handleRequest (package:shelf/shelf_io.dart:140:16) [0-0] <asynchronous suspension> [0-0] (elided 8 frames from class _AssertionError and dart:async) when running "element/35d08b1c-35d0-8b1c-35d0-8b1c35d08b1c/clear" with method "POST" [0-0] [2025-08-26T17:17:06.198Z] DEBUG: Screenshot taken on failure. [0-0] ✅ Test completed: should add new contact (FAILED) [0-0] unknown error in "Add Contact Page.should add new contact" unknown error: WebDriverError: An unknown server-side error occurred while processing the command. Original error: Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs. The test API method "pump" from class WidgetTester was called from dart:async/zone.dart on line 1414, but never completed before its parent scope closed. An uncaught exception may have caused the guarded function leak. The exception was: 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true. The stack trace associated with this exception was: #2 LiveTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1987:12) #3 WidgetTester.pump.<anonymous closure> (package:flutter_test/src/widget_tester.dart:667:53) #6 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) #7 WidgetTester.pump (package:flutter_test/src/widget_tester.dart:667:27) #8 WidgetTester.showKeyboard.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1139:13) #11 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) #12 WidgetTester.showKeyboard (package:flutter_test/src/widget_tester.dart:1127:27) #13 WidgetTester.enterText.<anonymous closure> (package:flutter_test/src/widget_tester.dart:1163:13) #16 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41) #17 WidgetTester.enterText (package:flutter_test/src/widget_tester.dart:1162:27) #18 ElementHelper.setText (package:appium_flutter_server/src/utils/element_helper.dart:73:18) #19 ClearHandler.handle (package:appium_flutter_server/src/handler/clear.dart:21:25) <asynchronous suspension> #20 RequestHandler.getHandler.<anonymous closure> (package:appium_flutter_server/src/handler/request/request_handler.dart:30:35) <asynchronous suspension> #21 _RouterPlusHandler._handler (package:shelf_plus/src/router_plus/router_plus.dart:64:16) <asynchronous suspension> #22 RouterEntry.invoke.<anonymous closure> (package:shelf_router/src/router_entry.dart:107:16) <asynchronous suspension> #23 RouterEntry.invoke (package:shelf_router/src/router_entry.dart:104:12) <asynchronous suspension> #24 Router.call (package:shelf_router/src/router.dart:184:26) <asynchronous suspension> #25 handleRequest (package:shelf/shelf_io.dart:140:16) <asynchronous suspension> (elided 8 frames from class _AssertionError and dart:async) when running "element/35d08b1c-35d0-8b1c-35d0-8b1c35d08b1c/clear" with method "POST" [0-0] [2025-08-26T17:17:06.204Z] DEBUG: Current main step finalized successfully [0-0] [Log Utils] Log process and stream stopped. [0-0] [Log Utils] Log process and stream stopped.

Error 2:
{"error":"unknown error","message":"An unknown server-side error occurred while processing the command. Original error: 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true.","stacktrace":"UnknownError: An unknown server-side error occurred while processing the command. Original error: 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true.\n at errorFromW3CJsonCode (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:1110:25)\n at ProxyRequestError.getActualError (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:979:14)\n at JWProxy.command (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:357:19)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at AppiumFlutterDriver.findElOrEls (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/build/src/commands/element.js:47:25)\n at AppiumFlutterDriver.findElOrElsWithProcessing (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:60:12)\n at AppiumFlutterDriver.findElement (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:75:12)"}

Appium Logs:
2025-08-27 15:16:16:212 [HTTP] --> POST /wd/hub/session/e57b3054-88be-4e1d-b242-eaf4562bf82d/element 2025-08-27 15:16:16:213 [HTTP] {"using":"-flutter key","value":"task_details_select_photos_button"} 2025-08-27 15:16:16:213 [AppiumFlutterDriver@3592] Calling AppiumDriver.findElement() with args: ["-flutter key","task_details_select_photos_button","e57b3054-88be-4e1d-b242-eaf4562bf82d"] 2025-08-27 15:16:16:213 [AppiumFlutterDriver@3592] Valid locator strategies for this request: xpath, css selector, id, name, class name, -android uiautomator, accessibility id, -ios predicate string, -ios class chain, key, semantics label, text, type, text containing, -flutter key, -flutter semantics label, -flutter text, -flutter type, -flutter text containing 2025-08-27 15:16:16:213 [WD Proxy] Matched '/element' to command name 'findElement' 2025-08-27 15:16:16:213 [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:10000/session/12b9f19a-7082-453f-9aef-a6fc3203e374/element] with body: {"strategy":"-flutter key","selector":"task_details_select_photos_button"} 2025-08-27 15:16:16:237 [WD Proxy] Got response with status 500: {"sessionId":"12b9f19a-7082-453f-9aef-a6fc3203e374","value":{"error":"unknown error","message":"'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true.","stackTrace":"#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:50:61)\n#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)\n#2 LiveTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:1987:12)\n#3 WidgetTester.pumpAndSettle.<anonymous closure> (package:flutter_test/src/widget_tester.dart:730:23)\n#4 _rootRun (dart:async/zone.dart:1414:13)\n#5 _CustomZone.run (dart:async/zone.dart:1317:19)\n#6 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:74:41)\n#7 WidgetTester.pumpAndSettle (package:flutter_test/src/widget_tester.dart:723:27)\n#8 ElementHelper.pumpAndTrySettle (package:appium_flutter_server/src/utils/element_helper.dart:560:20)\n#9 ElementHelper.waitFor (package:appium_flutter_server/src/u... 2025-08-27 15:16:16:237 [W3C] Matched W3C error code 'unknown error' to UnknownError 2025-08-27 15:16:16:238 [AppiumFlutterDriver@3592] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: 'package:flutter_test/src/binding.dart': Failed assertion: line 1987 pos 12: 'inTest': is not true. at errorFromW3CJsonCode (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:1110:25) at ProxyRequestError.getActualError (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/protocol/errors.js:979:14) at JWProxy.command (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:357:19) at processTicksAndRejections (node:internal/process/task_queues:95:5) at AppiumFlutterDriver.findElOrEls (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/build/src/commands/element.js:47:25) at AppiumFlutterDriver.findElOrElsWithProcessing (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:60:12) at AppiumFlutterDriver.findElement (/home/ltadmin/Documents/appium/2.2.1-29-7-25/node_modules/appium-flutter-integration-driver/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:75:12) 2025-08-27 15:16:16:238 [HTTP] <-- POST /wd/hub/session/e57b3054-88be-4e1d-b242-eaf4562bf82d/element 500 25 ms - 1682

capabilities

2025-08-27 15:14:34:258 [AndroidUiautomator2Driver@4a39] Creating session with W3C capabilities: { "alwaysMatch": { "platformName": "android", "appium:adbExecTimeout": "120000", "appium:autoAcceptAlerts": true, "appium:autoGrantPermissions": true, "appium:automationName": "FlutterIntegration", "appium:chromeOptions": { "args": [] }, "appium:chromedriverExecutableDir": "/appium/assets/drivers/chromedriver", "appium:chromedriverPorts": [ [ 11001, 11049 ] ], "appium:deviceName": "Galaxy S24", "appium:enableWebviewDetailsCollection": false, "appium:ensureWebviewsHavePages": false, "appium:headless": false, "appium:mode": "cloud", "appium:nativeWebScreenshot": true, "appium:newCommandTimeout": "0", "appium:orientation": "PORTRAIT", "appium:platformVersion": "14", "appium:systemPort": "12063", "appium:udid": "RFCXA097J4J", "appium:uiautomator2ServerLaunchTimeout": "60000", "appium:waitForQuiescence": false }, "firstMatch": [ {} ] }

appium_main.dart

`import 'package:appium_flutter_server/appium_flutter_server.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:lmn_crew/src/app.dart'; import 'package:lmn_crew/src/config/app_env_config.dart'; import 'package:lmn_crew/src/injection/injection.dart'; Future main() async { // Ensure the app is running with test binding await initializeTest( callback: (WidgetTester tester) async { const env = String.fromEnvironment("env", defaultValue: Env.qa); await configureDependencies(env: env); Bloc.transformer = (events, mapper) => events.asyncExpand(mapper); await tester.pumpWidget(const App()); }, ); }'

Sample Code

await browser.flutterScrollTillVisible({ finder: await browser.flutterByText("Widget Label") as unknown as WebdriverIO.Element, scrollDirection: "down" });
const dummyWidget = await browser.flutterByValueKey$("widgetKey");
await dummyWidget.click();

✅ Expected Behavior
Flutter integration APIs (pump, enterText, click, etc.) should run within test context without throwing "inTest" assertion failures.
Appium should not need to retry due to leaked async calls.

❌ Actual Behavior
Calls to pump / enterText trigger guarded async leaks.
Test API calls are considered out-of-scope.
Tests fail inconsistently with 500 UnknownError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions