ferridriver-bdd 0.4.0

BDD/Cucumber test framework for ferridriver. 144 built-in Gherkin steps backed by the Page API.
Documentation
//! Screenshot step definitions.

use crate::step::StepError;
use crate::world::BrowserWorld;
use ferridriver_bdd_macros::step;

#[step("I take a screenshot")]
async fn take_screenshot(world: &mut BrowserWorld) {
  world
    .page()
    .screenshot(ferridriver::options::ScreenshotOptions::default())
    .await
    .map_err(|e| StepError::wrap("screenshot", e))?;
}

#[step("I take a screenshot of {string}")]
async fn take_screenshot_of(world: &mut BrowserWorld, selector: String) {
  world
    .page()
    .locator(&selector, None)
    .screenshot()
    .await
    .map_err(|e| StepError::wrap(format!("screenshot of \"{selector}\""), e))?;
}

#[step("I take a snapshot")]
async fn take_snapshot(world: &mut BrowserWorld) {
  world
    .page()
    .snapshot_for_ai(ferridriver::snapshot::SnapshotOptions {
      depth: None,
      track: None,
    })
    .await
    .map_err(|e| StepError::wrap("snapshot", e))?;
}