0

我的英语不怎么好。对不起。

我有:

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

它的工作!

4

1 回答 1

0

如果您设置了浏览器启动方法,即

    函数设置()
      {
        $this->setBrowser("*firefox");
        $this->setBrowserUrl("http://www.google.com/");
      }

你的功能应该是这样的

    公共函数 testTitle()
    {
        $this->open('/');
        $this->assertEquals('我的标题。', $this->title());
    }

我改变了 $this -> url('/'); 到 $this -> open('/'); 请立即尝试。

于 2013-09-04T12:11:53.197 回答