问题
I am getting an ERROR: Unknown command: 'echo' executing a selenium script with phpunit. Based on the output that echo command should be included in my version of PHPUnit. The selenium script does execute successfully in the firefox selenium IDE.
mkdir_build:
phpunit:
[exec] PHPUnit 3.4.12 by Sebastian Bergmann.
[exec]
[exec] .
[exec] TestFull
[exec] E
[exec]
[exec] Time: 11 seconds, Memory: 6.50Mb
[exec]
[exec] There was 1 error:
[exec]
[exec] 1) TestFull::testNumberOne
[exec] PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
[exec] ERROR: Unknown command: 'echo'.
[exec]
[exec]
[exec] /directory/to/tests/TestFull.php:14
[exec]
[exec] FAILURES!
[exec] Tests: 1, Assertions: 0, Errors: 1.
And the RC server output:
$ java -jar selenium-server.jar -port 4445 -debug
13:23:08.426 INFO - Java: Sun Microsystems Inc. 14.2-b01
13:23:08.428 INFO - OS: Linux 2.6.28-15-server i386
13:23:08.439 INFO - v2.0 [a2], with Core v2.0 [a2]
13:23:08.439 INFO - Selenium server running in debug mode.
13:25:05.661 DEBUG - ---------retrieving CommandQueue for sel_93352
13:25:05.662 DEBUG - Browser 2c8b3b5657a640db9fb278ecbd01049e/:top sel_93352 posted ERROR: Unknown command: 'echo'
13:25:05.662 DEBUG - ---------retrieving CommandQueue for sel_93352
13:25:05.662 DEBUG - putting command: ERROR: Unknown command: 'echo'
13:25:05.662 DEBUG - ..command put?: true
13:25:05.662 DEBUG - sel_93352 commandHolder sel_93352 getCommand() called
13:25:05.662 DEBUG - waiting for data for at most 10 more s
13:25:05.662 DEBUG - data from polling: ERROR: Unknown command: 'echo'
13:25:05.662 DEBUG - sel_93352 commandResultHolder sel_93352 getResult() -> ERROR: Unknown command: 'echo'
13:25:05.663 DEBUG - Got result: ERROR: Unknown command: 'echo' on session 2c8b3b5657a640db9fb278ecbd01049e
13:25:05.663 INFO - Got result: ERROR: Unknown command: 'echo' on session 2c8b3b5657a640db9fb278ecbd01049e
13:25:05.663 DEBUG - Handled by org.openqa.selenium.server.SeleniumDriverResourceHandler in HttpContext[/selenium-server,/selenium-server]
13:25:05.663 DEBUG - RESPONSE:
HTTP/1.1 200 OK
Date: Wed, 07 Apr 2010 20:25:05 GMT
Server: Jetty/5.1.x (Linux/2.6.28-15-server i386 java/1.6.0_16
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Connection: close
回答1:
The Selenium IDE echo
command is not supported in Selenium RC, instead you should use your client language to echo out to file/console. For example, the following should print to console in PHP:
print("Print this!" . "\n");
来源:https://stackoverflow.com/questions/2595744/echo-command-not-found-while-testing-selenium-with-phpunit