" org.openqa.selenium.SessionNotCreatedException"用于硒网格

时间:2018-01-05 13:05:36

标签: selenium selenium-webdriver selenium-grid

我正在尝试将脚本运行到另一个虚拟机,但它会给我以下错误消息。

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'BDQCC3', ip: '10.132.48.16', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: unknown"

我的代码是

public static void main(String[] args) throws MalformedURLException 
 {
    // TODO Auto-generated method stub
    WebDriver driver;
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setBrowserName("chrome");
    capabilities.setPlatform(Platform.WIN10);
    driver = new RemoteWebDriver(new URL("http://10.132.48.16:5566/wd/hub"), capabilities);
    driver.get("http://google.com");
    System.out.println(driver.getTitle());  
 }

1 个答案:

答案 0 :(得分:0)

似乎在网格节点(10.132.48.16)上执行的注册到网格集线器(10.132.48.16)的命令不正确。我怀疑命令错过了选项:-Dwebdriver.chrome.driver=来指定chromedriver的路径。

注册命令示例:

java -jar %~dp0\selenium-server-standalone-2.45.0.jar -role node -nodeConfig node.json -Dwebdriver.chrome.driver=%~dp0\chromedriver.exe

登录网格节点10.132.48.16,停止注册过程并检查注册命令是否正确,也请将命令放在此处以帮助我们解决问题。