Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dont attempt to connect to the Selenium server at import; Check at the start of every test.
class SeleniumTestCase(LiveServerTestCase):
@property
def selenium_server_running(self):
"""
Determine if we can connect to the Selenium RC server.
"""
try:
conn = httplib.HTTPConnection(settings.SELENIUM_SERVER_HOST,
settings.SELENIUM_SERVER_PORT)
try:
conn.request("GET", "/selenium-server/driver/", '', {})
finally:
conn.close()
except socket.error:
return False
return True
def setUp(self):
if not self.selenium_server_running:
message = ("Can't connect to the Selenium server using address"
" %s and port %s" % (settings.SELENIUM_SERVER_HOST,
settings.SELENIUM_SERVER_PORT))
raise SkipTest(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.