我们正在Jenkins的Windows机器上进行硒测试。我在C:\ Selenium \ path下添加了ChromeDriver 2.36。我的Selenium_Server_standalone_2.53.0.jar位于C:\ Selenium下。 Chrome浏览器版本为65.执行测试时,我发现Chromedriver路径未正确设置问题。
**Path being added in config file :** ChromeDriver=C:/Selenium/path/SeleniumChromeDriver.exe
**Path being set in source code**:
String strChromeDriverPath = strConfigValues[18];
File fileChromeDriver = new File(strChromeDriverPath);
System.out.println("Chrome Driver Path: "+ fileChromeDriver.getAbsolutePath());
System.setProperty("webdriver.chrome.driver",fileChromeDriver.getAbsolutePath());
**Logs:**
01:49:43 [testng] Chrome Driver Path: C:\Selenium\path\SeleniumChromeDriver.exe
01:49:43 [testng] Starting ChromeDriver 2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91) on port 5553
01:49:43 [testng] Only local connections are allowed.
01:49:45 [testng] org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
01:49:45 [testng] Command duration or timeout: 17 milliseconds
答案 0 :(得分:0)
您看到的错误说明了一切:
01:49:43 [testng] Starting ChromeDriver 2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91) on port 5553
01:49:43 [testng] Only local connections are allowed.
01:49:45 [testng] org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
日志消息清楚地表明已检测到 ChromeDriver 2.36.540470 ,并且已成功启动浏览会话以打开浏览器客户端。< / p>
但是在浏览器客户端尝试与驱动程序服务器(即 ChromeDriver )进行通信的下一步中,通信作为路径失败最初为 JVM 所知的 ChromeDriver ,即 C:/Selenium/path/SeleniumChromeDriver.exe 可能已通过 Jenkins配置<更改< / strong>即可。由于浏览器客户端无法与之前已知位置的 ChromeDriver 进行通信,并且未找到 WebDriverException ,因此引发如下操作:
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property;