Selenium, php, phpUnit, 404 error calls testComplete() rather than continue, how do I stop this?
I am using selenium server and phpUnit to run php based tests. My tests a开发者_Python百科re simple, test the page is there, if it loads, has no errors on page and then move on. I have a missing page and rather than say, yep its not there and more on I get:
Time: 16 seconds, Memory: 14.75Mb
There was 1 error:
1) OlympicsSiteMapEnglishPages::testMyTestCase PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete(). XHR ERROR: URL = http://my.url/somepage Response_Code = 404 Error_Message = Not Found.
/some/path/some_file.php:375
FAILURES! Tests: 1, Assertions: 0, Errors: 1.
I really need to figure out how to stop it doing this! I have tried catching the exception like so:
try { $this->open("/rel/url.php", 1); } catch (PHPUnit_Framework_AssertionFailedError $e) { return array_push($this->verificationErrors, $e->toString()); }
Any clues guys, I really need help!
Many thanks,
Alex
PHPUnit_Framework_Exception
inherits fromException
PHPUnit_Framework_AssertionFailedError
inherits fromException
If you want to catch them both, you'll either have to catch the 'sort of expected' PHPUnit_Framework_Exception
earlier on (and possibly rethrow it as an PHPUnit_Framework_AssertionFailedError
), or resort to the generic try{} catch(Exception $e){}
Right after a bit of digging nothing works, so my hackie hack way which is very slow, it to try and open each url first using:
if(@fopen(rtrim($this->url, "/") . "/blah/blah/blah","r")) {
//do some test which should now not exit the browser as we know the page exists.
}
Please could some one find a much better way of doing things!
精彩评论