phpunit-selenium
phpunit-selenium copied to clipboard
PHPUnit_Extensions_Selenium2TestCase class is not taking any sreenshots
Hi,
I am having some difficulty making the PHPUnit_Extensions_Selenium2TestCase class to take a screenshot when a test fails. Here are my system configs:
Linux 2.6.32-279.el6.x86_64 amd64 Selenium v2.37.0 PHPUnit 3.7.29
What's interesting is... if I use PHPUnit_Extensions_SeleniumTestCase class, Selenium does take a screenshot and saves a .png file in the appropriate directory. But PHPUnit_Extensions_Selenium2TestCase class does not take any screenshot.
Here is my test class
<?php
class SampleControllerTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected $captureScreenshotOnFailure = TRUE;
protected $screenshotPath = "/home/<User>/<Application>/screenshots";
protected $screenshotUrl = 'http://localhost/<app>/screenshots';
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl("http://localhost/<app>/");
}
public function testObcCharts()
{
$this->url("http://localhost/<app>/");
$this->byId("link_obcs")->click();
$this->assertEquals("Sample Title", $this->byXpath("//h1")->text());
}
}
The API of these two classes are different: Selenium2TestCase provides a PHPUnit listener for taking screenshots of failures: https://github.com/sebastianbergmann/phpunit-selenium/blob/master/PHPUnit/Extensions/Selenium2TestCase/ScreenshotListener.php
Why is this not in the documentation?
The documentation of this project was inside PHPUnit's one originally, but since the two parted ways it's not possible to amend it (if it's still there).