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:
- Open your Flutter project in your preferred code editor.
- Locate the test_driver/app.dart file in your project.
-
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.
- 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
- Java.lang.illegalargumentexception: ‘producer’ type is unknown to reactiveadapterregistry
- The import org.springframework.web cannot be resolved
- Cannot deserialize value of type `java.time.localdatetime` from string
- ‘windows’ was deprecated in ios 15.0: use uiwindowscene.windows on a relevant window scene instead