I know that screenshots could be taken by extending PHPUnit_Extensions_Selenium2TestCase
but right now, I'm using Facebook's php-webdriver so I'm just extending with PHPUnit_Framework_TestCase
Is there anyway to take screenshots with this just the driver and not extending the extension?
Thanks.
$driver->takeScreenshot('/path/to/image.png');
I found such solution to make screenshot on failure:
/**
* {@inheritdoc}
*/
public function tearDown()
{
$status = $this->getStatus();
if ($status == \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR
|| $status == \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
$now = new \DateTime('now');
$screenshotFileName = $this->getParameter('screenshots_directory_full_path');
$screenshotFileName = $screenshotFileName . $now->format('Y-m-d H:i:s') . ' test ' . $this->getName() . '.png';
$this->webDriver->takeScreenshot($screenshotFileName);
}
$this->webDriver->quit();
}
You asked this long time ago, but hope it'll help somebody else :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With