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

使用Edge驱动获取网页表格列时遇WebDriverException错误求助

问题:Selenium提取表格列时触发WebDriverException错误

使用Python Selenium结合Edge驱动(版本119.0.2151.72)提取网页表格某列数据时,出现以下错误:

selenium.common.exceptions.WebDriverException: Message: unknown error: result.webdriverValue.value list is missing or empty in Runtime.callFunctionOn response
(Session info: MicrosoftEdge=119.0.2151.72)
tacktrace:
GetHandleVerifier [0x00E5C3B3+228579]
Microsoft::Applications::Events::time_ticks_t::time_ticks_t [0x00D3DE41+403697]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00B4CCB2+3906]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00B4FD75+16389]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00B51068+21240]
Microsoft::Applications::Events::ILogConfiguration::operator* [0x00B510F0+21376]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B7D9A8+104248]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B7DD5F+105199]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00BA4E82+265234]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B92B54+190692]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B77343+78035]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00BA37C0+259408]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B92866+189942]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B7664B+74715]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B75DFB+72587]
Microsoft::Applications::Events::GUID_t::GUID_t [0x00B76D4D+76509]
GetHandleVerifier [0x00F20092+1030594]
Microsoft::Applications::Events::FromJSON [0x00FEEF14+129108]
Microsoft::Applications::Events::FromJSON [0x00FEE8A5+127461]
Microsoft::Applications::Events::FromJSON [0x00FE4D5A+87706]
Microsoft::Applications::Events::FromJSON [0x00FEF919+131673]
Microsoft::Applications::Events::time_ticks_t::time_ticks_t [0x00D52313+486851]
Microsoft::Applications::Events::time_ticks_t::time_ticks_t [0x00D479B8+443496]
Microsoft::Applications::Events::time_ticks_t::time_ticks_t [0x00D47B21+443857]
Microsoft::Applications::Events::time_ticks_t::time_ticks_t [0x00D309F4+349348]
BaseThreadInitThunk [0x75316839+25]
RtlGetFullPathName_UEx [0x770B906F+1215]
RtlGetFullPathName_UEx [0x770B903D+1165]

解决方案
  • 验证元素定位准确性:确认用于定位表格列的XPath/CSS选择器是否有效。在Edge开发者工具控制台中,用$$("你的CSS选择器")或$x("你的XPath")测试,确保返回非空的元素集合。
  • 添加显式等待:表格可能动态加载,直接提取会因元素未就绪报错。使用显式等待确保元素可见:
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    
    # 等待目标列元素加载,最长等待10秒
    column_elements = WebDriverWait(driver, 10).until(
        EC.visibility_of_all_elements_located((By.XPATH, "//table//td[2]"))  # 替换为你的列索引
    )
    data = [elem.text for elem in column_elements]
    
  • 调整Selenium版本:该错误可能源于版本兼容问题,尝试升级或降级Selenium到与Edge驱动匹配的版本(推荐4.15.x及以上):
    pip install --upgrade selenium
    
  • 改用JavaScript提取:如果直接定位元素失败,通过JS脚本获取表格数据:
    # 示例:提取id为target-table的表格第2列数据(索引从0开始)
    column_data = driver.execute_script("""
        const table = document.getElementById('target-table');
        const result = [];
        for (let i = 1; i < table.rows.length; i++) {
            result.push(table.rows[i].cells[1].textContent.trim());
        }
        return result;
    """)
    
  • 确认浏览器与驱动版本一致:检查Edge浏览器版本是否与驱动完全匹配(版本号需精确到最后一位),不一致则下载对应版本的驱动替换。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 20:35:54