Chrome更新后Selenium ChromeDriver初始化超时问题求助
ChromeDriver初始化超时问题求助
更新Chrome至v110.0.5481.178后,初始化Selenium ChromeDriver时持续报错:The HTTP request to the remote WebDriver server for URL http://localhost:58801/session timed out after 60 seconds.
代码未做任何修改,且相同代码在另一台安装了完全相同Chrome版本的笔记本上可正常运行,对此我感到困惑。
另外,每次打开浏览器(手动或通过Selenium启动)都会弹出提示:Restore Pages - Chrome didn't shut down correctly,清理缓存后该弹窗暂时消失,但HTTP超时问题仍存在,且多次打开浏览器后弹窗会再次出现。
已尝试的解决方案
- 关闭Chrome设置中的
Continue running background apps when Google Chrome is closed选项 - 禁用所有浏览器扩展
- 创建全新项目,使用最简代码测试,错误依旧
- 清理浏览器缓存
相关版本信息
- Chrome版本:v110.0.5481.178
- Chromedriver版本:110.0.5481.7700
- Selenium版本:3.141.0
原初始化代码
var options = new ChromeOptions(); ChromeOptions co = new ChromeOptions(); co.AddUserProfilePreference("profile.default_content_setting_values.clipboard", 1); co.AddUserProfilePreference("download.default_directory", m_downloadDirectory); co.AddUserProfilePreference("download.prompt_for_download", false); co.AddUserProfilePreference("disable-popup-blocking", "true"); co.AddArguments("--no-sandbox"); string ChromeDriverLocalEnvironmentVariable = Environment.GetEnvironmentVariable("CHROMEWEBDRIVER", EnvironmentVariableTarget.Machine); string chromeDriverPath = ChromeDriverLocalEnvironmentVariable != null ? ChromeDriverLocalEnvironmentVariable : AppDomain.CurrentDomain.BaseDirectory; m_driver = new ChromeDriver(chromeDriverPath, co);
最简测试代码
static void Main(string[] args) { // Set up the Chrome driver IWebDriver driver = new ChromeDriver(); // Navigate to Google.com driver.Navigate().GoToUrl("https://www.google.com"); // Do something with the page here // Close the browser driver.Quit(); }
CMD启动日志
Starting ChromeDriver 110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839}) on port 64437 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. DevTools listening on ws://127.0.0.1:64478/devtools/browser/e7cfe558-6c8a-473b-a6ac-ca72a0f60d4c
恳请各位提供帮助,万分感谢。
内容的提问来源于stack exchange,提问作者JumpIntoTheWater
相关产品推荐
相关产品推荐

