Skip to content

Commit

Permalink
Delete screenshots at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Fonseca committed Jul 28, 2016
1 parent 936e092 commit df82c7b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Driver/GiffyDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ public function giffy()
$gc = new \GifCreator\GifCreator();
$gc->create($frames, $durations);
$gifBinary = $gc->getGif();
$gifFilename = $this->getScreenshotDestination().DIRECTORY_SEPARATOR.sprintf('%03d', $this->i).'_giffied.gif';
$gifFilename = $this->getScreenshotDestination().DIRECTORY_SEPARATOR.$this->giffyScenarioShotsPath.'.gif';
file_put_contents($gifFilename, $gifBinary);
echo "| Gif captured ~> ".$gifFilename.PHP_EOL.PHP_EOL;

foreach ($this->screenshotsTaked as $screenshot) {
unlink($screenshot);
}
}

public function resetCounter()
{
$this->c = 0;
$this->i++;
$this->screenshotsTaked = [];
}
public function setScenarioPath($path)
{
Expand All @@ -75,11 +80,14 @@ private function getSerializedName($scenarioId, $stepId)
{
return 'shot_'.sprintf('%03d', $scenarioId).'_'.sprintf('%03d', $stepId).'.png';
}

private $screenshotsTaked = [];

private function saveScreenshot()
{
$screenshotFilename = $this->getScreenshotDestination().DIRECTORY_SEPARATOR.$this->getShotName();
file_put_contents($screenshotFilename, parent::getScreenshot());
error_log(PHP_EOL."| Screenshot captured ~> ".$screenshotFilename.PHP_EOL);
$this->screenshotsTaked[] = $screenshotFilename;
}
private function highlight($xpath)
{
Expand Down Expand Up @@ -158,7 +166,7 @@ public function getValue($xpath)
return parent::getValue($xpath);
}


public function setValue($xpath, $value)
{
$this->saveScreenshot();
Expand Down

0 comments on commit df82c7b

Please sign in to comment.