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

使用Selenium WebDriver访问本地XML及动态XML页面遇超时问题求助

Chrome WebDriver操作本地XML文件(file://协议)超时,HTTP协议正常

我在本地复现了一个问题:

  • 当用Chrome WebDriver通过http://localhost:63342/Testing_Prj/EXPORT.xml打开XML文件时,driver.page_source可以正常获取;
  • 但改用file:///E:/Testing_Prj/EXPORT.xml打开同一文件时,调用driver.page_source或其他WebDriver属性都会触发超时错误。

我的实际业务场景是:点击页面上的「Generate」按钮后,会在新标签页打开动态生成的XML数据(URL是动态的),切换到这个新窗口的句柄后,完全无法执行任何操作——不管是获取page_source还是执行execute_script,都会超时失败。

附EXPORT.xml的内容:

<?xml version="1.0" encoding="utf-16"?>
<teachers>
    <teacher>
        <name>Sam Davies</name>
        <age>35</age>
        <subject>Maths</subject>
    </teacher>
    <teacher>
        <name>Cassie Stone</name>
        <age>24</age>
        <subject>Science</subject>
    </teacher>
    <teacher>
        <name>Derek Brandon</name>
        <age>32</age>
        <subject>History</subject>
    </teacher>
</teachers>

恳请各位帮忙解答,谢谢!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 19:20:03