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

CEF应用中使用Selenium Edge Driver遇NoSuchElementException及ChromeDriver连接问题

CEF应用调试连接与元素定位问题

测试已启动的CEF应用时,尝试通过DebuggerAddress选项连接至该应用,使用的浏览器为Microsoft Edge 107.0.1418.24,对应驱动为msedgedriver 107.0.1418.24,配置的EdgeOptions代码如下:

EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.DebuggerAddress = "localhost:9222";
edgeOptions.AddArguments("window-size=1680x1050");
edgeOptions.AddArguments("no-sandbox");
Driver = new EdgeDriver(edgeOptions);
Driver.Navigate();

执行测试代码var item = Driver.FindElement(By.Id("tableItem"))时,抛出OpenQA.Selenium.NoSuchElementException,错误信息如下:

Message: 
OpenQA.Selenium.NoSuchElementException : no such element: Unable to locate element: {"method":"css selector","selector":"#tableItem"}
(Session info: MicrosoftEdge=107.0.1418.24)

根据CEF文档,测试CEF应用应使用ChromeDriver,但尝试使用时出现如下错误:

Message: 
OpenQA.Selenium.WebDriverException : unknown error: cannot connect to chrome at localhost:9222
from unknown error: unrecognized Chrome version: Edg/107.0.1418.24

使用的ChromeOptions代码如下:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("window-size=1680x1050");
chromeOptions.AddArguments("no-sandbox");
chromeOptions.DebuggerAddress = "localhost:9222";
Driver = new ChromeDriver(chromeOptions);
Driver.Navigate();

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.14 02:10:57