For example: from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get("http://stackoverflow.com/")
Like in requests
, requests.get
returns a status_code
.
How to know whether to loads the page successfully using selenium?
For example: from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get("http://stackoverflow.com/")
Like in requests
, requests.get
returns a status_code
.
How to know whether to loads the page successfully using selenium?
You can def a function to wait until the body is loaded, and use "ui" from selenium
from selenium import webdriver
from selenium.webdriver.support import ui
def page_is_loaded(driver):
return driver.find_element_by_tag_name("body") != None
driver = webdriver.Chrome("C:\chromedriver\chromedriver.exe")
driver.get("www.google.com")
wait = ui.WebDriverWait(driver, 10)
wait.until(page_is_loaded)