驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置-硒错误 [英] The path to the driver executable must be set by the webdriver.chrome.driver system property - Selenium Error
问题描述
我有一个令人发指的硒错误:
I have an infuriating Selenium error:
驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置
The path to the driver executable must be set by the webdriver.chrome.driver system property
这是我正在使用的代码:
Here is the code I am using:
Environment.SetEnvironmentVariable("webdriver.chrome.driver", @"C:\ChromeDriver\chromedriver.exe");
DesiredCapabilities capability = DesiredCapabilities.Chrome();
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
capability.SetCapability(ChromeOptions.Capability, options);
Uri url = new Uri("http://localhost:5050/wd/hub");
//error on this line
IWebDriver driver = new RemoteWebDriver(url, capability);
我在该位置的磁盘上有驱动程序.
I have the driver on disk, at the location.
硒服务器正在运行,如下所示:
The selenium server is running, as shown below:
我已将硒二进制文件添加为系统变量,如下所示:
I have added the selenium binary as a system variable, as shown below:
我也重新启动了服务器.
I have restarted the server too.
我想念什么?感觉好像我在正确地进行所有操作,但是没有用.
What am I missing? It feels as though I am doing everything correctly, but it's not working.
谢谢
推荐答案
使用新的硒(3.0),您应该使用:
With the new selenium, which is 3.0 you should use:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium-server-standalone-3.0.0-beta2.jar
如果您使用的硒版本低于3.0,则需要使用驱动程序反转硒的顺序,例如:
If you are using selenium version below 3.0 you need to reverse the order of selenium with the driver, like:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium_server.jar
还要确保硒服务器与chromedriver兼容. 要检查的另一件事是chrome浏览器是最新的.
Also make sure selenium server is compatible with chromedriver. Other thing to check is that chrome browser is up to date.
这篇关于驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置-硒错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!