jonsamwell / flutter_gherkin

A Gherkin parsers and runner for Dart and Flutter which is very similar to cucumber
MIT License
203 stars 110 forks source link

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

Open lravihs opened 11 months ago

linchen2chris commented 10 months ago

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

lravihs commented 10 months ago

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

linchen2chris commented 10 months ago
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),
);