Selenium RC 使用assertTextPresent抛出sessionsid不应该为空异常,仅phpunit 3.4错误?

发布于 2024-09-01 23:26:45 字数 1451 浏览 5 评论 0原文

我希望将我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫瑾少女 2024-09-08 23:26:45

实际上问题出在 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 to tearDown().

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文