我使用selenium和chromedriver登录到ancestry.com,但是它说它没有找到登录信息的id。它打开浏览器并进入页面,将to填充并登录。我已经在其他网站上尝试过,但它已经成功了,不知道为什么它不在这里工作。我试着让它睡上几秒钟,认为页面需要完全加载(来自初学者的知识)....Code在下面,如果有人遇到问题或者知道如何处理这个登录,我会很感激。
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
chrome_path= r"C:\Users\....\chromedriver_win32\chromedriver.exe"
driver= webdriver.Chrome(chrome_path)
driver.get("https://www.ancestry.com/account/signin")
sleep(15)
username= "username"
password= "password"
driver.find_element_by_id("username").send_keys(username)
driver.find_element_by_id("password").send_keys(password)
driver.find_element_by_id("signInBtn").click()
print("Logged in Successfully")发布于 2021-08-01 20:19:17
实际上,您需要切换到frame,我使用的是explicitWait而不是sleep
driver.get("https://www.ancestry.com/account/signin")
username= "username"
password= "password"
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it(driver.find_element_by_id("signInFrame")))
userName = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"username")))
userName.send_keys(username)
passWord = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"password")))
passWord.send_keys(password)
signIn = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.ID,"signInBtn")))
signIn.click()
print("Logged in Successfully")https://stackoverflow.com/questions/68613763
复制相似问题