You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python Selenium报错unable to discover open pages的排查与解决

解决Selenium WebDriverException: unknown error: unable to discover open pages错误

错误现象

运行Python Selenium代码时触发WebDriverException,错误信息为unknown error: unable to discover open pages,完整错误堆栈如下:

[2023-02-19 10:06:05,978]: rw_rule_crawling.py:175 ERROR ERROR :  
Traceback (most recent call last):
File "c:\\Lion\\lion-admin\\tasks\\rw_rule_crawling.py", line 132, in get_pending_rule
driver = init_driver()
File "c:\\Lion\\lion-admin\\tasks\\rw_rule_crawling.py", line 28, in init_driver
driver = webdriver.Chrome(options=chrome_options, executable_path=chrome_driver)
File "D:\\Users\\zhanni\\AppData\\Roaming\\Python\\Python38\\site-packages\\selenium\\webdriver\\chrome\\webdriver.py", line 69, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "D:\\Users\\zhanni\\AppData\\Roaming\\Python\\Python38\\site-packages\\selenium\\webdriver\\chromium\\webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "D:\\Users\\zhanni\\AppData\\Roaming\\Python\\Python38\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 266, in __init__
self.start_session(capabilities, browser_profile)
File "D:\\Users\\zhanni\\AppData\\Roaming\\Python\\Python38\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 357, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\\Users\\zhanni\\AppData\\Roaming\\Python\\Python38\\site-packages\\selenium\\webdriver\\remote\\webdriver.py", line 418, in execute
self.error_handler.check_response(response)
File "D:\\Users\\zhanni\\AppData\\Roaming\\Python\\Python38\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
Stacktrace:
Backtrace:
(No symbol) [0x00C837D3]
(No symbol) [0x00C18B81]
(No symbol) [0x00B1B36D]
(No symbol) [0x00B3ED6D]
(No symbol) [0x00B39B90]
(No symbol) [0x00B36FC9]
(No symbol) [0x00B71ED5]
(No symbol) [0x00B71B2C]
(No symbol) [0x00B6B216]
(No symbol) [0x00B40D97]
(No symbol) [0x00B4253D]
GetHandleVerifier [0x00EFABF2+2510930]
GetHandleVerifier [0x00F28EC1+2700065]
GetHandleVerifier [0x00F2C86C+2714828]
GetHandleVerifier [0x00D33480+645344]
(No symbol) [0x00C20FD2]
(No symbol) [0x00C26C68]
(No symbol) [0x00C26D4B]
(No symbol) [0x00C30D6B]
BaseThreadInitThunk [0x75C700F9+25]
RtlGetAppContainerNamedObjectPath [0x773E7BBE+286]
RtlGetAppContainerNamedObjectPath [0x773E7B8E+238]

排查过程

  • 尝试给ChromeOptions添加--no-sandbox参数,问题未解决
  • 检查代码发现存在自定义Chrome用户数据路径的配置:
chrome_user_data = os.getenv("LOCALAPPDATA") + r"\\Google\\Chrome\\User Data"
  • 前往该路径核实,发现Google文件夹已消失,推测是系统更新或Chrome自动更新导致路径变更

解决方法

删除上述自定义Chrome用户数据路径的配置代码,重新运行程序,问题成功解决。

内容的提问来源于stack exchange,提问作者zhanni

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 15:48:31