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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)