Selenium RC throws sessionid不应为assertTextPresent的null异常,仅适用于phpunit 3.4 bug? [英] Selenium RC throws sessionsid should not be null exception with assertTextPresent, phpunit 3.4 bug only?

查看:104
本文介绍了Selenium RC throws sessionid不应为assertTextPresent的null异常,仅适用于phpunit 3.4 bug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将我的硒RC测试迁移到使用PHPUnit 3.3.2中的PHPUnit 3.4.12.

当我使用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?.

例如:

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

下面是硒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(),测试将很高兴结束.

有什么想法吗?

解决方案

实际上问题出在setAutoStop()方法上-默认情况下它设置为TRUE,因此PHPUnit在tearDown()之前向Selenium RC发送停止信号.

$this->setAutoStop(false);添加到setUp()方法中,并将$this->stop();添加到tearDown()的末尾.

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?

解决方案

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().

这篇关于Selenium RC throws sessionid不应为assertTextPresent的null异常,仅适用于phpunit 3.4 bug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆