Ext.flutter.driver is not found in “extensionrpcs”

The error message “ext.flutter.driver is not found in ‘extensionrpcs'” typically occurs when the Flutter driver extension is not properly registered or enabled in your Flutter project. The Flutter driver extension allows you to write integration tests for your app and interact with the UI elements programmatically.

To resolve this issue, you need to make sure that the Flutter driver extension is set up correctly. Here’s a step-by-step guide:

  1. Open your Flutter project in your preferred code editor.
  2. Locate the test_driver/app.dart file in your project.
  3. Make sure that the following code is present in app.dart:

                   import 'package:flutter_driver/driver_extension.dart';
                   import 'package:your_flutter_app/main.dart' as app;
    
                   void main(){
                       enableFlutterDriverExtension();
                       app.main();
                   }
               

    You should replace ‘your_flutter_app’ with the relevant package name of your Flutter app.

  4. Save the app.dart file and reload/run your Flutter project.

By correctly registering the Flutter driver extension, you should now be able to use the ‘ext.flutter.driver’ extension in your tests.

Here’s an example of how you can use the Flutter driver extension to find and tap a button in your Flutter app:

           // Import the necessary packages
           import 'package:flutter_driver/flutter_driver.dart';
           import 'package:test/test.dart';

           void main() {
               group('Testing My Flutter App', () {
                   FlutterDriver driver;

                   setUpAll(() async {
                       driver = await FlutterDriver.connect();
                   });

                   tearDownAll(() async {
                       if (driver != null) {
                           driver.close();
                       }
                   });

                   test('Tap the button', () async {
                       SerializableFinder buttonFinder = find.byValueKey('my_button');
                       await driver.tap(buttonFinder);
                   });
               });
           }
       

Similar post

Leave a comment