fix: not taking screenshots for errored tests. needs to be better

This commit is contained in:
James 2020-01-29 18:09:38 +00:00
parent ba63cceeb1
commit 208bedc7ff

View File

@ -11,7 +11,7 @@ abstract class BrowserTest extends \PHPUnit_Extensions_Selenium2TestCase{
public function setUp(){
$this->setHost('localhost');
$this->setPort(4444);
$args=explode(',',getenv('SeleniumBrowserArgs'));
$args=explode(' ',getenv('SeleniumBrowserArgs'));
$args[]='screenshot';
$this->setDesiredCapabilities(['moz:firefoxOptions'=>['args'=>$args]]);
$this->setBrowserUrl(getenv('SeleniumBrowserUrl'));
@ -19,12 +19,13 @@ abstract class BrowserTest extends \PHPUnit_Extensions_Selenium2TestCase{
}
public function tearDown(){
if ($this->hasFailed()) {
//echo "STAT:".$this->getStatus()."\n";
// if ($this->hasFailed()) {
if($path=getenv('SeleniumScreenshotPath')){
$filedata = $this->currentScreenshot();
file_put_contents($path.get_class($this).'::'.$this->getName().'.png', $filedata);
}
}
// }
$this->stop();
}