【发布时间】:2013-02-10 21:37:49
【问题描述】:
我希望将我的 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?
如您所见,测试应该已完成,如“Killing Firefox”位所示,但它继续执行其他操作并触发导致异常的 getLocation[, ] 命令。
我已尝试使用 PHPUnit 3.3.2 进行相同的测试,但没有产生此问题 - 如果没有 getLocation(),测试将愉快地结束。
有什么想法吗?
【问题讨论】:
-
在 PHPUnit 3.3.2 中通过了完全相同的测试?在 Selenium 会话停止后,您的拆解中似乎有一些东西。有任何自定义侦听器吗?
-
嗨戴夫,感谢您的评论。我的拆解中有以下内容:protected function tearDown() { if ($this->autoStop) { try { $this->stop(); } 捕捉 (RuntimeException $e) { } } }
标签: selenium phpunit selenium-rc