PHPUnit Selenium captureScreenshotOnFailure does not work?

倖福魔咒の 提交于 2019-12-01 06:46:32

The error handling of this is rather poor on phpunit's part; if everything isn't perfect it will silently ignore your other options without a warning.

As Dave mentioned, if any of the variables are misspelled it will silently not work, and you might also try assigning them to the instance in your setUp.

Also, not every condition triggers a screenshot. Try $selenium->assertTextPresent("foobarbaz") instead of your $selenium->fail() for a sanity check.

battcor

you may try adding these line of codes


    try {
        $this->assertTrue($this->isTextPresent("You searched for \"Brakes\" (2 matches)"));
    } catch (PHPUnit_Framework_AssertionFailedError $e) {
        array_push($this->verificationErrors, $e->toString());
        $this->drivers[0]->captureEntirePageScreenshot($this->screenshotPath . DIRECTORY_SEPARATOR . rawurlencode($this->getLocation()) . '.png');
    }

I recently had this error because I was following the tutorial.

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

Perhaps change

extends PHPUnit_Extensions_Selenium2TestCase

to

extends PHPUnit_Extensions_SeleniumTestCase
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!