captureAutomaticScreenshotForStepBestEffort method

Future<bool> captureAutomaticScreenshotForStepBestEffort({
  1. required TestStepExecutor executor,
  2. required TestStep step,
  3. required int stepIndex,
  4. TestStep? labelStep,
  5. bool pumpBeforeCapture = false,
  6. bool ensureTargetVisible = true,
  7. bool waitForTarget = false,
  8. bool waitForLottie = true,
  9. bool stabilize = true,
  10. bool forFailure = false,
  11. ObservationDetailLevel observationDetail = ObservationDetailLevel.standard,
  12. bool requireVisibleActionHighlight = false,
})

Implementation

Future<bool> captureAutomaticScreenshotForStepBestEffort({
  required TestStepExecutor executor,
  required TestStep step,
  required int stepIndex,
  TestStep? labelStep,
  bool pumpBeforeCapture = false,
  bool ensureTargetVisible = true,
  bool waitForTarget = false,
  bool waitForLottie = true,
  bool stabilize = true,
  bool forFailure = false,
  ObservationDetailLevel observationDetail = ObservationDetailLevel.standard,
  bool requireVisibleActionHighlight = false,
}) async {
  try {
    return await _captureAutomaticScreenshotForStep(
      executor: executor,
      step: step,
      stepIndex: stepIndex,
      labelStep: labelStep,
      pumpBeforeCapture: pumpBeforeCapture,
      ensureTargetVisible: ensureTargetVisible,
      waitForTarget: waitForTarget,
      waitForLottie: waitForLottie,
      stabilize: stabilize,
      forFailure: forFailure,
      observationDetail: observationDetail,
      requireVisibleActionHighlight: requireVisibleActionHighlight,
    );
  } catch (error) {
    // Screenshot capture must never replace the real test failure, but a
    // silent drop makes a missing first-step artifact impossible to explain.
    // Keep the diagnostic lightweight and in the normal per-test log so it
    // is available in the report without changing the execution result.
    logStandaloneScreenshotCaptureFailure(
      context: executor.context,
      step: step,
      stepIndex: stepIndex,
      error: error,
    );
    return false;
  }
}