2017-03-22 14:16
浏览 65


I want to learn about ui testing with selenium in phpunit. I had phpunit installed on my cakephp project, and it was running perfectly. Then I decided to install selenium following the steps described in https://phpunit.de/manual/3.7/en/selenium.html (i installed selenium in my project with the following command $ php composer.phar require --dev phpunit/phpunit-selenium: ">=1.2". Now after starting the selenium server with its jar file, I have been trying to run the example test provided in the link above, but I am receiving the following error:

$ vendor/bin/phpunit

PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /var/www/html/ujols/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php on line 97

Seems like the error is related to the Selenium2TestCase.php file that was installed with the composer. This is how the Selenium2TestCase.php file starts:

abstract class PHPUnit_Extensions_Selenium2TestCase extends PHPUnit_Framework_TestCase

Is there anyone here who managed to install selenium on cakephp or any other php framework? I would be super grateful if you could help me fix the problem

EDIT the sample test case i ve been trying to run to check if selenium is working:



class WebTest extends PHPUnit_Extensions_Selenium2TestCase
    protected function setUp()

    public function testTitle()
        $this->assertEquals('Example WWW Page', $this->title());


图片转代码服务由CSDN问答提供 功能建议

我想了解ui在phpunit中使用selenium进行测试。 我在我的cakephp项目上安装了phpunit,它运行得很好。 然后我决定按照 https://phpunit.de/manual中描述的步骤安装selenium /3.7/en/selenium.html (我使用以下命令在我的项目中安装了selenium $ php composer.phar require --dev phpunit / phpunit-selenium:“&gt; = 1.2”</ code >。启动selenium服务器及其jar文件后,我一直在尝试运行上面链接中提供的示例测试,但是我收到以下错误:</ p>

< p> $ vendor / bin / phpunit </ p>

PHP致命错误:在 / var / www / html / ujols / vendor / phpunit / phpunit-selenium中找不到类 'PHPUnit_Framework_TestCase' 第97行上的/PHPUnit/Extensions/Selenium2TestCase.php </ p> </ blockquote>

似乎该错误与随作曲家一起安装的Selenium2TestCase.php文件有关。 是Selenium2TestCase.php文件的启动方式:</ p>

 抽象类PHPUnit_Extensions_Selenium  2TestCase扩展PHPUnit_Framework_TestCase 
 </ code> </ pre> 

这里是否有人设法在cakephp或任何其他php框架上安装selenium? 如果你能帮助我解决这个问题,我将非常感激</ p>

编辑我试图运行的样本测试用例以检查硒是否正常工作:</ p>

PlainviewTest.php </ p>

class WebTest扩展PHPUnit_Extensions_Selenium2TestCase 
 protected function setUp()
 $ this-&gt  ; setBrowser('firefox'); 
 $ this-&gt; setBrowserUrl('http://www.example.com/'); 
 $ this  - &gt; url('http://www.example.com/'); 
 $ this-&gt; assertEquals('示例WWW Page',$ this-&gt; title()); 
 \  n} 
 </ code> </ pre> 
 </ div>

1条回答 默认 最新

相关推荐 更多相似问题