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

Chrome Driver配合Karate 1.0.1调用Page.getFrameTree无法获取frameTree

我此前发布的相关问题已经通过将Karate升级到0.9.6版本解决:When using the chrome driver with Karate UI the driver.send command is not working

但在我将Karate升级到1.0.1版本后,原本在0.9.6中正常运行的代码失效了。我查阅了官方文档,文档内容未发生变更:DevTools Protocol 相关说明

运行如下代码时,即使驱动日志中已经输出了我需要的frameTree,我也无法获取到预期的frameTree返回值:

Scenario: Get Frame Tree
    * driver 'https://google.com'
    * def frame = driver.send({ method: 'Page.getFrameTree' })
    * print frame

实际输出如下:

17:01:26.738 [main] DEBUG c.intuit.karate.driver.DriverOptions - >> {"id":7,"method":"Page.getFrameTree"}
17:01:26.749 [nioEventLoopGroup-2-1] DEBUG c.intuit.karate.driver.DriverOptions - << {"id":7,"result":{"frameTree":{"frame":{"id":"EF7B9A896E378D2847F3A5FD6647353E","loaderId":"74EA753CFFDB150AE371D4CC442E0B8C","url":"https://www.google.com/","domainAndRegistry":"google.com","securityOrigin":"https://www.google.com","mimeType":"text/html","adFrameType":"none","secureContextType":"Secure","crossOriginIsolatedContextType":"NotIsolated","gatedAPIFeatures":["SharedArrayBuffersTransferAllowed"]}}}}
17:01:26.750 [main] INFO com.intuit.karate - [print] {
"id": 7,
"method": null
}

请问这是1.0.x版本的bug吗?我尝试过1.0.1RC5版本,也存在相同问题。

补充更新

我后续会仔细排查,但目前没有明确头绪。我之前的实现虽然能正常运行但属于非官方支持的用法,我的需求是获取无法解析的页面的URL,对应代码如下:

Scenario: GetUnreachableURL
    * string frameTree = driver.send(karate.toMap({ method: 'Page.getFrameTree' }))
    * print frameTree
    # 无头模式下Chrome遇到不可访问URL不会返回chrome-error标识
    * def unreachableUrl = driver.url == 'chrome-error://chromewebdata/' ?  karate.extract(frameTree, 'unreachableUrl=(.+?)(?=,|})', 1) : driver.url

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.11 08:27:04