'integrationDriver in integration_test_driver.dart has documentation for a parameter named onScreenshot but does not have the actual implementation
flutter/packages/integration_test/lib/integration_test_driver.dart
/// onScreenshotcan be used to process the screenshots taken during the test. /// An example could be that this callback compares the byte array against a baseline image, /// and it returnstrueif both images are equal. /// /// As a result, returningfalsefromonScreenshot will make the test fail.
But in flutter/packages/integration_test/lib/integration_test_driver_extended.dart have onScreenshot() callback but does not have responseDataCallback() parameter: though in both cases it return null after all test case execution. How to capture screenshot using flutter/packages/integration_test/lib/integration_test_driver.dart package if it doesn't not contain onScreenshot() callback?
https://github.com/flutter/flutter/issues/94881
Flutter doctor:
`C:\Users\Ext07696\FlutterProjects\signify-bics-frontend>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.62.2)
[√] Connected device (2 available)
• No issues found!``
Solution 1:[1]
It does have. You can use like this:
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:integration_test/integration_test_driver_extended.dart';
Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
await integrationDriver(
driver: driver,
onScreenshot: (String screenshotName, List<int> screenshotBytes) async {
final File image = File('screenshots/$screenshotName.png');
image.writeAsBytesSync(screenshotBytes);
// Return false if the screenshot is invalid.
return true;
},
);
}
Solution 2:[2]
You need to use the 'import 'package:integration_test/integration_test_driver_extended.dart' import.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dean Nguyen |
| Solution 2 | Scott |
