phpunit-selenium icon indicating copy to clipboard operation
phpunit-selenium copied to clipboard

PHPUnit_Extensions_Selenium2TestCase class is not taking any sreenshots

Open rooseveltrp opened this issue 11 years ago • 3 comments

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());
    }
}

rooseveltrp avatar Jan 23 '14 20:01 rooseveltrp

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

giorgiosironi avatar Jan 25 '14 16:01 giorgiosironi

Why is this not in the documentation?

MCMic avatar May 18 '16 04:05 MCMic

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).

giorgiosironi avatar May 22 '16 21:05 giorgiosironi