簡體   English   中英

PHPUnit +硒2.35 = BadMethodCallException

[英]PHPUnit + Selenium 2.35 = BadMethodCallException

我的英語不怎么好。 抱歉。

我有:

PHPUnit 3.7.24
Selenium 2.35.0

我正在啟動硒服務器:

java -jar /usr/local/bin/selenium-server-standalone-2.35.0.jar 

輸出:

04.09.2013 13:51:15 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
13:51:25.373 INFO - Java: Sun Microsystems Inc. 20.45-b01
13:51:25.374 INFO - OS: Linux 3.8.0-29-generic i386
13:51:25.388 INFO - v2.35.0, with Core v2.35.0. Built from revision c916b9d
13:51:25.542 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
13:51:25.543 INFO - Version Jetty/5.1.x
13:51:25.544 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
13:51:25.545 INFO - Started HttpContext[/selenium-server,/selenium-server]
13:51:25.546 INFO - Started HttpContext[/,/]
13:51:25.567 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@dda25b
13:51:25.567 INFO - Started HttpContext[/wd,/wd]
13:51:25.571 INFO - Started SocketListener on 0.0.0.0:4444
13:51:25.577 INFO - Started org.openqa.jetty.jetty.Server@b61fd1

我的簡單測試:

public function testTitle()
{
    $this->url('/');
    $this->assertEquals('My title.', $this->title());
}

接下來,使用以下命令運行phpunit test:

phpunit --debug functional/MainPageTest.php

輸出:

PHPUnit 3.7.24 by Sebastian Bergmann.

Configuration read from /home/demyan112rv/www/boo/protected/tests/phpunit.xml
Starting test 'MainPageTest::testTitle'.
E

Time: 17.59 seconds, Memory: 2.75Mb
There was 1 error:

1) MainPageTest::testTitle
PHP Warning:  include(PHPUnit_Extensions_Story_TestCase.php): failed to open stream: No such file or directory in /home/demyan112rv/www/yii/YiiBase.php on line 421
PHP Warning:  include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.php' for inclusion (include_path='.:/home/demyan112rv/www/boo/protected/helpers:/home/demyan112rv/www/boo/protected/widgets:/home/demyan112rv/www/boo/protected/extensions/mail:/home/demyan112rv/www/boo/protected/services:/home/demyan112rv/www/boo/protected/components:/home/demyan112rv/www/boo/protected/models:/usr/share/php:/usr/share/pear') in /home/demyan112rv/www/yii/YiiBase.php on line 421
BadMethodCallException: The command http://localhost:4444/wd/hub/session/url is not recognized by the server.

/home/demyan112rv/www/yii/test/CWeb2TestCase.php:60
/home/demyan112rv/www/boo/protected/tests/functional/MainPageTest.php:11
/home/demyan112rv/www/boo/protected/tests/functional/MainPageTest.php:11

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

這次在selenium服務器中有一個下一個輸出:

13:55:39.438 INFO - Executing: [new session: {browserName=firefox}] at URL: /session)
13:55:39.452 INFO - Creating a new session for Capabilities [{browserName=firefox}]
13:55:56.642 INFO - Done: /session

我有錯誤“ BadMethodCallException:服務器無法識別命令http:/ / localhost:4444 / wd / hub / session / url。”。 鏈接為2.35修復了此錯誤,但是我有2.35,並且我有此錯誤。

如何解決這個問題?

解決方案 (我無法回答我的問題,因為我的評分低於10。

$ whereis phpunit
phpunit: /usr/bin/phpunit /usr/bin/X11/phpunit /usr/local/bin/phpunit

我有3 phphunit的路徑。 我不知道,這是正常的還是沒有。

當我從以下命令更改命令時:

phpunit --debug functional/MainPageTest.php

/usr/bin/phpunit --debug functional/MainPageTest.php

它正在工作!!!

如果您已經設置了瀏覽器啟動方法,即

function setUp()
      {
        $this->setBrowser("*firefox");
        $this->setBrowserUrl("http://www.google.com/");
      }

您的功能應如下所示

public function testTitle()
    {
        $this->open('/');
        $this->assertEquals('My title.', $this->title());
    }

我已經更改了$ this-> url('/'); 到$ this-> open('/'); 請立即嘗試。

暫無
暫無

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

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