我刚刚通过"pear install phpunit/PHPUnit_Selenium"安装了PHPUnit Selenium扩展。系统目前仍在使用 PHP 5.2,所以我必须使用 PHPUnit_Extension_SeleniumTestCase 而不是PHPUnit_Extension_Selenium2TestCase。我一直在尝试运行 PHPUnit 文档中给出的基本测试:
<?php
class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.example.com/');
}
public function testTitle()
{
$this->url('http://www.example.com/');
$this->assertEquals('Example WWW Page', $this->title());
}
}
?>
但是,由于以下原因,测试中的测试结果被跳过:
1) WebTest::testTitle
Could not connect to the Selenium Server on localhost:4444.
Z:applicationsxampplitephpphpunit:46
有人对我为什么会遇到这个问题有任何建议吗?多谢!
解决方案是一个愚蠢的解决方案。我没有启动并运行Selenium服务器。如果您有同样的问题,请确保从Selenium下载页面下载服务器,然后在尝试测试之前启动jar。