处理 Selenium RC 打开方法失败 (404)

发布于 2024-09-07 05:06:31 字数 651 浏览 1 评论 0原文

我有一个循环来检查 url 是否存在。如果不存在,则 Selenium 退出: XHR 错误:URL = http://localhost/pages/156.php Response_Code = 404 Error_Message = Not Found.

如果我捕获异常:

try {
     $this->selenium->open($url);
}
catch(PHPUnit_Framework_Exception $e) { echo "caught\n"; }

之后我执行的任何操作都会出现此错误: 错误服务器异常:sessionId 不应为 null;这个会话已经开始了吗?

我什至尝试按预期设置异常:

$this->selenium->setExpectedException('PHPUnit_Framework_Exception');

但会话仍然停止并且测试完成。我怎样才能让 Selenium 继续测试 url?谢谢。

I have a loop that checks for the existence of urls. If one does not exist Selenium exits:
XHR ERROR: URL = http://localhost/pages/156.php Response_Code = 404 Error_Message = Not Found.

If i catch the exception:

try {
     $this->selenium->open($url);
}
catch(PHPUnit_Framework_Exception $e) { echo "caught\n"; }

Anything i do afterwards gives me this error:
ERROR Server Exception: sessionId should not be null; has this session been started yet?

I even tried to set the exception as expected:

$this->selenium->setExpectedException('PHPUnit_Framework_Exception');

But still the session is stopped and the test is completed. How can i make Selenium keep testing the urls? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

不知在何时 2024-09-14 05:06:31

为每个 url 创建新的 selenium 实例!

$this->selenium = new Testing_Selenium("*firefox", "http://your-app-under-test.org/");
$result = $this->selenium->start();
$this->selenium->open("/the-page-to-test.php");

或参见http://pear.php。 net/package/Testing_Selenium/docs/0.4.3/Selenium/Testing_Selenium.html#method__construct 供参考,构造函数有更多参数。

Create new selenium instance for every url!

$this->selenium = new Testing_Selenium("*firefox", "http://your-app-under-test.org/");
$result = $this->selenium->start();
$this->selenium->open("/the-page-to-test.php");

or see http://pear.php.net/package/Testing_Selenium/docs/0.4.3/Selenium/Testing_Selenium.html#method__construct for reference, there are more arguments to the constructor.

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