-
Notifications
You must be signed in to change notification settings - Fork 117
Description
@jonsamwell Getting error while taking screenshot after step execution, Could you please provide work around ASAP if possible because reports without screenshots doesnt make much sense?
Note:-in 3.0,0-rc-9 , It was working fine.
Sample code and error below:
AttachScreenshotStepHook.onAfterStep function:
Run after a step has executed
@override
Future<void> onAfterStep(
World world, String step, StepResult stepResult) async {
logger.i("onAfterStep '$step' ${stepResult.result}");
try {
final screenshotData = await takeScreenshot(world);
world.attach(screenshotData, 'image/png', step);
} catch (e, st) {
world.attach('Failed to take screenshot\n$e\n$st', 'text/plain', step);
}
return super.onAfterStep(world, step, stepResult);
}
}
Future<String> takeScreenshot(World world) async {
final bytes = await (world as FlutterWorld).appDriver.screenshot();
return base64Encode(bytes);
}
tter (15208): └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── I/flutter (15208): - Then User clicks on create invoice button # :0 took 300ms I/flutter (15208): Attachment (text/plain): Failed to take screenshot I/flutter (15208): 'package:integration_test/_callback_io.dart': Failed assertion: line 73 pos 12: '!_isSurfaceRendered': Surface already converted to an image I/flutter (15208): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61) I/flutter (15208): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5) I/flutter (15208): #2 IOCallbackManager.convertFlutterSurfaceToImage (package:integration_test/_callback_io.dart:73:12) I/flutter (15208): #3 IntegrationTestWidgetsFlutterBinding.convertFlutterSurfaceToImage (package:integration_test/integration_test.dart:204:27) I/flutter (15208): #4 WidgetTesterAppDriverAdapter.screenshot (package:flutter_gherkin/src/flutter/adapters/widget_tester_app_driver_adapter.dart:72:21) I/flutter (15208): #5 takeScreenshot (file:///myrepo/integration_test/gherkin/hooks/screenshots_hooks.dart:72:57) I/flutter (15208): #6 AttachScreenshotStepHook.onAfterStep