开发者

Handle Selenium RC open method failure (404)

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->ope开发者_运维百科n($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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜