簡體   English   中英

使用phpunit在cakephp中進行硒測試

[英]selenium testing in cakephp with phpunit

我想了解phpunit中使用硒進行的ui測試。 我在cakephp項目上安裝了phpunit,它運行得很好。 然后我決定按照https://phpunit.de/manual/3.7/en/selenium.html中描述的步驟安裝selenium(我在我的項目中使用以下命令將selenium安裝到了以下命令$ php composer.phar require --dev phpunit/phpunit-selenium: ">=1.2" 。現在,使用其jar文件啟動selenium服務器之后,我一直在嘗試運行上面鏈接中提供的示例測試,但是我收到以下錯誤:

$ vendor / bin / phpunit

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

似乎該錯誤與隨作曲者安裝的Selenium2TestCase.php文件有關。 這是Selenium2TestCase.php文件的啟動方式:

abstract class PHPUnit_Extensions_Selenium2TestCase extends PHPUnit_Framework_TestCase
{

這里有人設法在cakephp或任何其他php框架上安裝硒嗎? 如果您能幫助我解決問題,我將不勝感激

編輯我一直試圖運行的示例測試用例,以檢查硒是否正常工作:

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());
    }

}
?>

我在@ndm的很多幫助下找到了一種將硒與phpunit集成到我的應用程序中的方法,這些步驟如下:

按照此處的簡單安裝步驟- 使用Selenium WebDriver + PHPUnit進行測試

*確保您的新ui測試與單元測試不在同一個文件夾中,我在同一個文件夾中,並且始終遇到致命錯誤。

*如果運行./vendor/bin/steward run staging firefox命令返回錯誤,則將firefox更改為chrome。 如果仍然像我一樣繼續出現錯誤,請安裝chromedriver並再次運行。 它應該工作。

確實值得所有努力。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM