【问题标题】:Simple PHP Selenium test doesn't work简单的 PHP Selenium 测试不起作用
【发布时间】:2010-09-30 22:13:15
【问题描述】:

我在 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 的类似乎有点奇怪。有什么想法吗?

【问题讨论】:

    标签: php selenium phpunit


    【解决方案1】:

    您应该为 PHPUnit read the docs 用于命令行测试运行程序。您也可以从命令行运行“phpunit --help”。我相信你会发现你需要运行类似

    的东西
    phpunit path/to/filename.php
    

    【讨论】:

      猜你喜欢
      • 2018-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-19
      • 2012-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多