处理 Selenium RC 打开方法失败 (404)
我有一个循环来检查 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为每个 url 创建新的 selenium 实例!
或参见http://pear.php。 net/package/Testing_Selenium/docs/0.4.3/Selenium/Testing_Selenium.html#method__construct 供参考,构造函数有更多参数。
Create new selenium instance for every url!
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.