Skip to content

Request for guidance: Unreliable Dart Observatory connection when using Appium Flutter Driver + byValueKey locators #862

@nickyar

Description

@nickyar

Dear Appium-Flutter Team,
I am writing to seek technical guidance on a persistent integration issue between Flutter and Appium for UI automation.
Project context:

Flutter version: 3.41.6 (stable channel, managed via FVM)
Appium version: 3.2.2
Automation name: Flutter
Device: Pixel 2 emulator (Android 11)
Host: Ubuntu 25.10 on MacBook Pro (ARM)
We use appium_flutter_finder + FlutterFinder.by_value_key()

Widgets are properly instrumented:
In our login screen (login_page.dart), every interactive widget has both ValueKey and Semantics:

DartSemantics(
identifier: 'email_input',
label: 'email_input',
child: FormBuilderTextField(
key: const ValueKey('email_input'),
...
),
)

(The same pattern is used for password_input and login_button.)
We also call enableFlutterDriverExtension(); as the first statement in main.dart (before WidgetsFlutterBinding.ensureInitialized() and runApp()).
The exact problem:
Even though:

The Appium session successfully starts and reports both NATIVE_APP and FLUTTER contexts,
We can manually launch the app from Android Studio,
We see the Observatory URL in Logcat sometimes,

the command flutter:connectObservatoryWsUrl (and the three retry strategies with different payloads) consistently fails with one of the following:

"Cannot connect to the Dart Observatory URL ws://127.0.0.1:XXXXX/.../ws"
"No observatory URL matching ... was found in the device log"

As a result, we never reach the stage of using byValueKey("email_input"), flutter:waitFor, flutter:tap, or flutter:enterText.
We have tried:

Manual launch outside driver + flutter:connectObservatoryWsUrl
Automatic launch via capabilities
Different timeout/isolate payloads
Full flutter clean + pub get after fixing pubspec conflicts (intl, etc.)

Our goal:
A reliable Flutter-only automation path using Widget Finder / byValueKey / FLUTTER context without falling back to native locators (UiAutomator2, accessibility ID, XPath).
Could the Flutter team please advise on:

Any recent changes in the VM service extension (ext.flutter.driver) or Observatory discovery that might affect Appium Flutter Driver?
Recommended best practices for stable Observatory attachment in emulator environments with FVM?
Whether there are plans to improve the official flutter_driver integration with external tools like Appium (e.g., more robust port discovery or a dedicated extension API)?

Any suggestions, workarounds, or pointers to internal documentation would be greatly appreciated. I am happy to provide a minimal reproducible repository or Logcat/Appium logs if helpful.
Thank you for your continued work on Flutter and for any assistance you can provide.
Best regards,
Nick

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions