Search code examples
phptestingseleniumphpunitscreenshot

captureScreenshotOnFailure not working, broken


I can't get these screenshots working for the life of me:

Should be pretty simple, but there's no error messages, nothing. Can anyone shed some light before I start digging into the source?

class ScreenshotTest extends PHPUnit_Extensions_Selenium2TestCase {
    protected $captureScreenshotOnFailure = TRUE;
    protected $screenshotPath = 'C:\\';
    protected $screenshotUrl = 'http://127.0.0.1/';

    protected function setUp()
    {
        $this->setBrowser('firefox');
        $this->setBrowserUrl('http://127.0.0.1/');
    }

    public function testTitle()
    {
        $this->url('http://127.0.0.1');
        $this->assertEquals('foobarbaz', $this->title());
    } }

Solution

  • Ah ha - found the problem.

    extends PHPUnit_Extensions_Selenium2TestCase
    

    should be

    extends PHPUnit_Extensions_SeleniumTestCase
    

    Gotcha!

    The first example in the documentation is for PHPUnit_Extensions_Selenium2TestCase. All of the others on the page are for PHPUnit_Extensions_SeleniumTestCase.

    Edit

    This question started me on one of those search-for-answers-for-days struggles. For the next guy/gal having this trouble, there's a few beginner-level headaches that aren't explicitly stated anwhere and I documented them at Where the heck is any Selenium 2 documentation for PHPUnit?.