Selenium RC throws sessionsid should not be null exception with assertTextPresent, phpunit 3.4 bug only?

删除回忆录丶 提交于 2019-12-23 12:26:12

问题


I am looking to migrate my selenium RC tests to using PHPUnit 3.4.12 from PHPUnit 3.3.2.

The selenium test will fail with an exception of the following when I use assertTextPresent():

PHPUnit_Framework_Exception: Response from Selenium RC server for getLocation().
ERROR Server Exception: sessionId should not be null; has this session been started yet?.

For example:

public function testSending($browser)
{
   ...
   $browser->click("send");
   $browser->waitForPageToLoad("30000");
   $browser->assertTextPresent("text");                
}

Below is the selenium RC log (running on Windows):

15:40:19.676 INFO - Command request: isTextPresent[text, ] on session 153d03a123c42098711994f43c2db34
15:40:19.691 INFO - Got result: OK,false on session 153d023a123c42098711994f43cdb34
15:40:19.879 INFO - Command request: testComplete[, ] on session 153d023a123c4298711994f43c2db34
15:40:19.879 INFO - Killing Firefox...
15:40:20.269 INFO - Got result: OK on session 153d023a123c42098711994f43c2db34
15:40:20.472 INFO - Command request: getLocation[, ] on session null
15:40:20.472 ERROR - Exception running 'getLocation 'command on session null
java.lang.NullPointerException: sessionId should not be null; has this session been started yet?

As you can see, the test should have completed as indicated by the "Killing Firefox" bit, but it instead continued to do something else and triggered the getLocation[, ] command which caused the exception.

I have tried the same test with PHPUnit 3.3.2 which did not produce this problem - the test would happily end without the getLocation().

Any ideas?


回答1:


Actually the problem is with setAutoStop() method - by default it's set to TRUE, so PHPUnit sends stop signal to Selenium RC prior to tearDown().

Add $this->setAutoStop(false); to your setUp() method and $this->stop(); to the end of tearDown().



来源:https://stackoverflow.com/questions/2846928/selenium-rc-throws-sessionsid-should-not-be-null-exception-with-asserttextpresen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!