selenium Chrome更新到113.0.5672.127后Pythone脚本无法工作

ivqmmu1c  于 2023-05-17  发布在  Python
关注(0)|答案(2)|浏览(245)

已将Chrome更新为113.0.5672.127,下载了ChromeDriver 113.0.5672.63,但脚本停止工作。看起来像第一行脚本,我试图操纵页面上的元素是不工作,现在无论如何。
错误文本示例:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//iframe"}
  (Session info: headless chrome=113.0.5672.127)

以及:

WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[starts-with(@ng-click,'clickEdit')]"))).click()

这是字面上的第一行,他们工作了几个月。有人能帮我弄明白问题出在哪里吗?
尝试使用其他版本的ChromDriver,但没有帮助。
编辑:
因此,经过一些研究,我发现页面有一个错误,这个错误是我的问题的原因,但看起来错误是由我的脚本更新后,在那里摆在首位。现在页面是不可用的,因为这个错误,但我有类似的网页,可以重新创建的过程。
看起来像如果我运行脚本"chrome_options. add_argument("--headless ")"(我想chrome被隐藏)我在cmd窗口得到这个消息:DevTools正在侦听ws://www.example.com [0517/124106.941:INFO:CONSOLE(0)]"自动聚焦处理被阻止,因为文档已经具有聚焦元素。","link"。127.0.0.1:52759/devtools/browser/05d5b34e-667c-4beb-a9a8-d87a52a3dd82 [0517/124106.941:INFO:CONSOLE(0)] "Autofocus processing was blocked because a document already has a focused element.", "link".
在此之后,有一个错误在此页面和页面是不可用后,我。但是如果我在没有错误的页面上运行没有"chrome_options. add_argument("--headless ")"的脚本-一切都很好。一些疯狂的事情正在发生,有人能帮助了解发生了什么吗?

wqsoz72f

wqsoz72f1#

尝试使用**Webdriver Manager for Python**似乎可以工作(尽管我在Mac上,所以我的Chrome版本是113.0.5672.126而不是Windows的127),这里是一个最小的例子:

import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

# Setup Chrome options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--remote-debugging-port=9222")
# Setup WebDriver
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
# Navigate to google.com
driver.get("https://google.com")
# Close the driver after 10 seconds
time.sleep(10)
driver.quit()
y53ybaqx

y53ybaqx2#

在俄语栈溢出中得到了答案。需要编辑自

chrome_options.add_argument("--headless")

chrome_options.add_argument("--headless=new")

更多关于主题:下载与 chrome 无头和 selenium

相关问题