duandan4680 2017-03-22 14:16
浏览 65
已采纳

使用phpunit在cakephp中进行硒测试

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:

PlainviewTest.php

<?php

class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
    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条回答 默认 最新

  • 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)