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”。启动selenium服务器及其jar文件后,我一直在尝试运行上面链接中提供的示例测试,但是我收到以下错误:

< p> $ vendor / bin / phpunit

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

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

 抽象类PHPUnit_Extensions_Selenium  2TestCase扩展PHPUnit_Framework_TestCase 

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



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} 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqqs64238 2017-03-24 16:04

    I figured a way to get selenium integrated with phpunit in my app with a lot of help from @ndm, here are the steps:

    Follow the easy installation steps here - Testing with Selenium WebDriver + PHPUnit

    *Make sure your new ui-tests are not in the same folder with unit tests, I had mine in the same folder and kept getting fatal errors.

    *If running the ./vendor/bin/steward run staging firefox command returns an error, then change firefox to chrome. If you still keep getting error (like I did), install chromedriver and run again. It should work.

    It was really worth all the effort.

    打赏 评论

相关推荐 更多相似问题