gpt4 book ai didi

python - Selenium Python 错误

转载 作者:太空宇宙 更新时间:2023-11-04 04:38:12 24 4
gpt4 key购买 nike

我正在尝试创建一个能够登录到 gmail 的小型测试程序。到目前为止,该程序在 chrome 上打开了网站,但实际上无法在“输入电子邮件”表单框中键入任何内容。此外,我在 shell 中收到一个错误,这可能会提供对我的问题的洞察力。

驱动程序版本:2.40Chrome 版本:67.0.3396.99

代码如下:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver= webdriver.Chrome('C:\chromedriver_win32\chromedriver.exe')
driver.get("http://mail.google.com")
emailid=driver.find_element_by_name("identifier")
emailid.send_keys("samplekeys")

错误如下:

Traceback (most recent call last):
File "C:\gmail.py", line 7, in <module>
driver.get("http://mail.google.com")
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 332, in get
self.execute(Command.GET, {'url': url})
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: missing or invalid 'entry.level'
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.17134 x86_64)

如有任何帮助,我们将不胜感激!

最佳答案

试试这个:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains

browser = webdriver.Chrome(executable_path = r'C:/chromedriver_win32/chromedriver.exe')
browser.get("http://mail.google.com")

wait = WebDriverWait(browser, 10)

user_name = wait.until(EC.element_to_be_clickable((By.ID, 'identifierId')))
user_name.click()
user_name.send_keys("samplekeys")

关于python - Selenium Python 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51196799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com