Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Waiting For responses in selenium
from selenium import webdriver
from import WebDriverWait
class WaitBrowser(object):
def __init__(self, **kw):
self.browser = webdriver.PhantomJS()
def readystate_complete(self):
# AFAICT Selenium offers no better way to wait for the document to be loaded,
# if one is in ignorance of its contents.
return self.browser.execute_script("return document.readyState") == "complete"
def wait(self, timeout=30):
WebDriverWait(self.browser, timeout).until(self.readystate_complete)
wb = WaitBrowser()
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.