セレンテストを実行するために PHPUnit 3.4.12 を使用しています。テストが失敗したときにスクリーンショットを自動的に取得できるようにしたいと考えています。これは、 http://www.phpunit.de/manual/current/en/selenium.html#selenium.seleniumtestcase.examples.WebTest2.phpで説明されているようにサポートされている必要があります。
class WebTest
{
protected $captureScreenshotOnFailure = true;
protected $screenshotPath = 'C:\selenium';
protected $screnshotUrl = 'http://localhost/screenshots';
public function testLandingPage($selenium)
{
$selenium->open("http://www.example.com");
$selenium->fail("fail");
...
}
}
ご覧のとおり、テストが失敗するようにしています。理論的には、失敗した場合は、スクリーンショットを取得して C:\selenium に配置する必要があります。これは、Windows で Selenium RC サーバーを実行しているためです。
ただし、テストを実行すると、次のようになります。
[root@testbox selenium]$ sh run
PHPUnit 3.4.12 by Sebastian Bergmann.
F
Time: 8 seconds, Memory: 5.50Mb
There was 1 failure:
1) WebTest::testLandingPage
fail
/home/root/selenium/WebTest.php:32
FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
C:\selenium にスクリーンショットがありません。ただし、 $selenium->captureScreenshot("C:/selenium/image.png"); でスクリーンショットを取得できます。
アイデアや提案は大歓迎です。
ありがとう