Search code examples
error-handlingseleniumselenium-rc

Don't stop on HTTP error 403


In one of my Selenium test cases, I try to ensure that certain pages can't be accessed. Instead, HTTP return code 403 should be given.

However, here Selenium terminates test execution with the following exception:

com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://user:[email protected]/admin Response_Code = 403 Error_Message = Forbidden

Any way to work around that?


Solution

  • Seems like I have to answer the question myself...

    I now surround the "open" call with a try...catch block. There, I parse the exception message if it contains the 403 code and XHR ERROR. Seems to me not very clean, but it works.