flutter_gherkin icon indicating copy to clipboard operation
flutter_gherkin copied to clipboard

Can we take screenshot wherever we wanted.?despite of fail scenario

Open lravihs opened this issue 2 years ago • 3 comments
trafficstars

lravihs avatar Jul 27 '23 09:07 lravihs

you can call context.world.appDriver.screenshot() in your step to take screenshot

linchen2chris avatar Aug 22 '23 08:08 linchen2chris

@linchen2chris can you provide me the sample code because I am not able to import world.

lravihs avatar Aug 22 '23 09:08 lravihs

import 'package:flutter_gherkin/flutter_gherkin.dart';
import 'package:gherkin/gherkin.dart';

/// take a screenshot
///
/// Examples:
///
///   `When the screenshot "xxx" is taken
///   xxx.png will be taken in screenshot folder
///
final takeScreenshotStep = when1<String, FlutterWidgetTesterWorld>(
  RegExp(r'(?:a|an|the|) screenshot {string} is taken$'),
  (screenshotName, context) async {
    print("going to step: takeScreenshotStep");
    await context.world.appDriver.waitForAppToSettle();
    var data = await context.world.appDriver
        .screenshot(screenshotName: screenshotName);

    await context.world.appDriver.waitForAppToSettle();
  },
  configuration: StepDefinitionConfiguration()
    ..timeout = const Duration(seconds: 30),
);

linchen2chris avatar Aug 23 '23 01:08 linchen2chris