Nov-02-2017, 11:49 AM
the time it takes to load a webpage can be different for each person, depending on your internet speed and computer, etc.
@OP I added the above example in for wait until elements
@OP I added the above example in for wait until elements
from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from bs4 import BeautifulSoup import time EMAIL = '' PASSWORD = '' CHROMEPATH = '' login_url = 'https://www.google.com/accounts/Login' browser = webdriver.Chrome(CHROMEPATH) browser.set_window_position(0,0) wait = WebDriverWait(browser, 2) presence = EC.presence_of_element_located visible = EC.visibility_of_element_located browser.get(login_url) wait.until(presence((By.ID, 'identifierId'))) browser.find_element_by_id("identifierId").send_keys(EMAIL) browser.find_element_by_id("identifierNext").click() wait.until(presence((By.NAME, 'password'))) browser.find_element_by_name("password").send_keys(PASSWORD) browser.find_element_by_id("passwordNext").click() wait.until(visible((By.CSS_SELECTOR, '#gb > div.gb_zd.gb_5d > div.gb_yc.gb_lb.gb_xc.gb_Zd > div > div.gb_ib.gb_4c.gb_yg.gb_R.gb_pf.gb_pb > div > a > span'))) soup = BeautifulSoup(browser.page_source, 'html.parser') print(soup.prettify())
Recommended Tutorials: