Last Updated: February 25, 2016
· jonahlyn

Testing HTTP Status Codes (Selenium)

I'm just getting started learning how to use Selenium for testing web apps and I was a bit shocked to find that access to the HTTP status code was not possible (since 2009!).

This seems to get the job done as a workaround:

import urllib2

class MyunmTestCase(unittest.TestCase):

    def test_something(self):
        request = urllib2.urlopen("")
        self.assertEqual(request.getcode(), 200)


Not sure how 'pro' this is but it works for me for now.