简单的 PHP Selenium 测试不起作用
我在 PHP 中有以下 Selenium 测试:
<?php
require_once('PHPUnit/Extensions/SeleniumTestCase.php');
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp()
{
$this->setBrowser("*chrome");
$this->setBrowserUrl("http://change-this-to-the-site-you-are-testing/");
}
public function testMyTestCase()
{
$this->open("/frontend_dev.php");
try {
$this->assertTrue($this->isTextPresent("Local Coupons"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
}
}
当我尝试运行它(通过运行“php filename.php”)时,我收到错误:
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 60
这是有道理的,因为该类没有在任何地方定义,但为什么不呢?我安装了 PHPUnit。 PHPUnit 中不包含名为 PHPUnit_Framework_TestCase 的类,这似乎有点奇怪。有什么想法吗?
I have the following Selenium test in PHP:
<?php
require_once('PHPUnit/Extensions/SeleniumTestCase.php');
class Example extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp()
{
$this->setBrowser("*chrome");
$this->setBrowserUrl("http://change-this-to-the-site-you-are-testing/");
}
public function testMyTestCase()
{
$this->open("/frontend_dev.php");
try {
$this->assertTrue($this->isTextPresent("Local Coupons"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
}
}
When I try to run it (by running "php filename.php") I get the error:
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 60
Which makes sense because the class isn't defined anywhere, but why not? I installed PHPUnit. It seems a little weird that a class called PHPUnit_Framework_TestCase wouldn't be included with PHPUnit. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该阅读 PHPUnit 命令行测试运行程序的文档。您也可以从命令行运行“phpunit --help”。我相信你会发现你需要运行类似的东西
You should read the docs for PHPUnit for the command line test runner. You can also just run 'phpunit --help' from the command line. I believe you'll find that you need to instead run something like