繁体   English   中英

错误:selenium.common.exceptions.TimeoutException:消息:

[英]error: selenium.common.exceptions.TimeoutException: Message:

在下面的代码中,我尝试使用 selenium 登录网站,但我收到此错误 selenium.common.exceptions.TimeoutException: 消息:

提前致谢

代码

 from selenium import webdriver from bs4 import BeautifulSoup from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By URL = 'website' options = webdriver.ChromeOptions() options.add_argument("headless") options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_experimental_option('excludeSwitches', ['enable-logging']) driver = webdriver.Chrome(options=options) driver.get(URL) wait = WebDriverWait(driver, 10) #------------------------------------------------------------------- wait.until(EC.presence_of_element_located((By.ID,"username"))).send_keys("nocsud") wait.until(EC.presence_of_element_located((By.ID,"value"))).send_keys("noc_sud10") driver.find_element_by_id("submitDataverify").click() #------------------------------------------------------------------- soup = BeautifulSoup(driver.page_source, 'html.parser') driver.quit() root = soup.find(id='root') print(root)

我建议您使用 options.add_argument("interactive") 让您查看网页中发生的情况以及代码在哪里停止,可能找不到您在 DOM 中搜索的元素之一 wait.until( EC.presence_of_element_located((By.ID,"username"))).send_keys("nocsud") wait.until(EC.presence_of_element_located((By.ID,"value"))).send_keys("noc_sud10")

尝试检查“值”或“用户名”是否是 ID 或名称

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM