You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a means to share step workflows with testers, I knocked together this extremely crude addition to ScreenshotContext this morning. It captures a screenshot of each step of a tagged scenario (probably erring on the side of too many screenshots, really), and means a tester can see the output frame by frame.
From here it would not be far to output a video artefact.
useFeatureTrait, ScenarioTrait;
/** * Record every step with a screenshot, if tagged with 'screenshot-vcr'. * * @AfterStep */publicfunctionrecordStepScreenshots($event)
{
$tagName = 'screenshot-vcr';
/** @var \Behat\Behat\Hook\Scope\BeforeStepScope $event */if (!$this->getScenario()->hasTag($tagName) && !$this->getFeature()->hasTag($tagName)) {
return;
}
$driver = $this->getSession()->getDriver();
$stepText = $event->getStep()->getText();
$stepLine = $event->getFeature()->getFile() . '-' . $event->getStep()->getLine();
$fileName = $this->makeFileName('html', preg_replace('/[^a-zA-Z0-9-]+/', '-', $stepLine . '-' . $stepText));
try {
$data = $driver->getContent();
} catch (DriverException$exception) {
// Do not do anything if the driver does not have any content - most// likely the page has not been loaded yet.return;
}
$this->saveScreenshotData($fileName, $data);
try {
$data = $driver->getScreenshot();
// Preserve filename, but change the extension - this is to group// content and screenshot files together by name.$fileName = substr($fileName, 0, -1 * strlen('html')).'png';
$this->saveScreenshotData($fileName, $data);
} catch (UnsupportedDriverActionException$exception) {
// Nothing to do here - drivers without support for screenshots// simply do not have them created.
}
}
Any thoughts on the approach @AlexSkrypnyk ? I'd love to contribute this in a way that makes sense alongside the rest of the project, or perhaps you know of existing solutions I'm not aware of.
Happy to turn into a PR if you want, but I don't feel it's at that level of quality yet 😁
The text was updated successfully, but these errors were encountered:
As a means to share step workflows with testers, I knocked together this extremely crude addition to ScreenshotContext this morning. It captures a screenshot of each step of a tagged scenario (probably erring on the side of too many screenshots, really), and means a tester can see the output frame by frame.
From here it would not be far to output a video artefact.
Any thoughts on the approach @AlexSkrypnyk ? I'd love to contribute this in a way that makes sense alongside the rest of the project, or perhaps you know of existing solutions I'm not aware of.
Happy to turn into a PR if you want, but I don't feel it's at that level of quality yet 😁
The text was updated successfully, but these errors were encountered: