首页 > 解决方案 > selenium 错误 WebDriverException:未知错误:asp 核心中没有 chrome 二进制文件

问题描述

我在 asp core 3.1 中使用 selenium,在本地它正在工作,但在 server windows 2012 中出现错误:

WebDriverException:未知错误:没有 chrome 二进制文件

我设置二进制和驱动程序:

var chromeOptions = new ChromeOptions();
chromeOptions.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";            
_driver = new ChromeDriver(Path.Combine(hostingEnvironment.WebRootPath), chromeOptions);

但不工作

标签: selenium

解决方案


在本地这有效,因为它是与您的系统相关的绝对路径。

chromeOptions.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; 

这当然不会在服务器上工作,因为这会失败,因为它不是同一条路径。理想情况下,您希望使用相对路径样式。


推荐阅读