Selenium RC 使用assertTextPresent抛出sessionsid不应该为空异常,仅phpunit 3.4错误?
我希望将我的 selenium RC 测试从 PHPUnit 3.3.2 迁移到使用 PHPUnit 3.4.12。
当我使用 assertTextPresent()
时,selenium 测试将失败,但以下情况除外:
PHPUnit_Framework_Exception: Response from Selenium RC server for getLocation().
ERROR Server Exception: sessionId should not be null; has this session been started yet?.
例如:
public function testSending($browser)
{
...
$browser->click("send");
$browser->waitForPageToLoad("30000");
$browser->assertTextPresent("text");
}
下面是 selenium RC 日志(在 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?
如您所见,测试应该已完成如“杀死 Firefox”位所示,但它继续执行其他操作并触发导致异常的 getLocation[, ] 命令。
我已经尝试使用 PHPUnit 3.3.2 进行相同的测试,但没有产生此问题 - 如果没有 getLocation()
,测试会愉快地结束。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上问题出在
setAutoStop()
方法上 - 默认情况下它设置为 TRUE,因此 PHPUnit 在tearDown()
之前向 Selenium RC 发送停止信号。将
$this->setAutoStop(false);
添加到您的setUp()
方法,并将$this->stop();
添加到tearDown() 结束
。Actually the problem is with
setAutoStop()
method - by default it's set to TRUE, so PHPUnit sends stop signal to Selenium RC prior totearDown()
.Add
$this->setAutoStop(false);
to yoursetUp()
method and$this->stop();
to the end oftearDown()
.