Skip to content

Commit

Permalink
Merge pull request #90 from DanTalash/master
Browse files Browse the repository at this point in the history
Using relative screenshot path instead of a hardcoded folder
  • Loading branch information
dutchiexl authored Jun 12, 2018
2 parents 618bb31 + 923cffe commit 878084a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Classes/Scenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ public function setScreenshotPath($string)
*/
public function getScreenshotPath()
{
if (file_exists('results/html/' . $this->screenshotPath)) {
return $this->screenshotPath;
if (file_exists($this->screenshotPath)) {
return "file://" . realpath($this->screenshotPath);
}

return false;
}
}
3 changes: 2 additions & 1 deletion src/Formatter/BehatHTMLFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ public function onBeforeScenarioTested(BeforeScenarioTested $event)
$scenario->setLine($event->getScenario()->getLine());
$scenario->setScreenshotName($event->getScenario()->getTitle());
$scenario->setScreenshotPath(
'assets/screenshots/' .
$this->printer->getOutputPath() .
'/assets/screenshots/' .
preg_replace('/\W/', '', $event->getFeature()->getTitle()) . '/'.
preg_replace('/\W/', '', $event->getScenario()->getTitle()) . '.png'
);
Expand Down

0 comments on commit 878084a

Please sign in to comment.