【发布时间】:2015-04-02 15:21:24
【问题描述】:
我将 PHPUnit 4.6 和 PHPUnit Selenium 1.4.2 与 PhantomJS 一起使用。当硒测试失败时,我想用最后一页截屏。 在PHPUnit Manual 中有一个 Selenium 1 的示例,但我正在尝试使用 Selenium 2,因为我需要使用 GhostDriver。
WebTestCase.php
class WebTestCase extends PHPUnit_Extensions_Selenium2TestCase
{
protected $captureScreenshotOnFailure = TRUE;
protected $screenshotPath = '/../../screenshots';
protected $screenshotUrl = 'http://localhost:8080/screenshots';
protected function setUp() {
$this->setBrowser('phantomjs');
$this->setBrowserUrl("http://localhost:8080");
$this->setHost('localhost');
}
}
Test.php
class Test extends WebTestCase
{
public function testTitle()
{
$this->url('');
assertEquals($this->title(), "My App");
}
}
但这不是截图。
$ vendor/bin/phpunit
PHPUnit 4.6-ge85198b by Sebastian Bergmann and contributors.
Configuration read from /MyApp/phpunit.xml
F
Time: 231 ms, Memory: 5.50Mb
There was 1 failure:
1) Test::testTitle
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-''
+'My App'
/MyApp/tests/functional/Test.php:7
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
【问题讨论】:
标签: testing selenium phpunit phantomjs ghostdriver