【问题标题】:Selenium testing is throwing webdriver exceptionSelenium 测试抛出 webdriver 异常
【发布时间】:2018-03-20 21:05:51
【问题描述】:

我们正在 Jenkins 的 windows Machine 中进行硒测试。我在 C:\Selenium\path 下添加了 ChromeDriver 2.36。我的 Selenium_Server_standalone_2.53.0.jar 放在 C:\Selenium 下。 Chrome 浏览器版本为 65。在执行测试时,我发现 Chrome 驱动程序路径设置不正确。

**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

【问题讨论】:

  • 你在String strChromeDriverPath = strConfigValues[18];中到底在做什么?
  • @DebanjanB 可能从字符串数组中获取字符串,我猜是这个 C:/Selenium/path/SeleniumChromeDriver.exe
  • 我建议使用最新的 chrome 驱动进行测试,也可以尝试将字符串设置为 C:\\Selenium\\path\\SeleniumChromeDriver.exe

标签: java google-chrome selenium selenium-webdriver selenium-chromedriver


【解决方案1】:

您看到的错误说明了一切:

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 被检测到,并且 浏览会话 已成功启动以打开 浏览器客户端

但在下一步中,当 Browser Client 尝试与 Driver ServerChromeDriver 通信时,通信失败作为路径ChromeDriver 最初为 JVM 所知,即 C:/Selenium/path/SeleniumChromeDriver.exe 可能已通过 Jenkins 配置。由于 Browser Client 无法在先前已知的位置与 ChromeDriver 进行通信并且没有找到它,因此引发了 WebDriverException,如下所示:

org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property;

【讨论】:

    猜你喜欢
    • 2016-09-16
    • 2017-07-23
    • 2013-02-22
    • 2018-07-14
    • 1970-01-01
    • 1970-01-01
    • 2017-11-25
    • 2012-02-07
    相关资源
    最近更新 更多