我已经像这样启动了hub和node:
#!/bin/bash
java -jar /opt/selenium/selenium-server-standalone-3.7.1.jar -role hub &
java -jar /opt/selenium/selenium-server-standalone-3.7.1.jar -role webdriver -hub http://192.168.40.40:4444/grid/register -nodeConfig /opt/selenium/defaultNodeConfig.json -browser "browserName=chrome,platform=LINUX" &
这是my/opt/selenium/defaultNodeConfig。json:
{
"capabilities": [
{
"browserName": "firefox",
"platform": "LINUX",
"maxInstances": 5,
"cleanSession": true,
"webdriver.gecko.driver": "/opt/selenium/geckodriver",
"webdriver.firefox.bin": "/usr/bin/firefox"
},
{
"browserName": "chrome",
"platform": "LINUX",
"maxInstances": 5,
"webdriver.chrome.driver": "/opt/selenium/chromedriver"
}
]
}
当我启动Selenium客户端连接到集线器时,如下所示:
#!/bin/bash
java -cp ".:/opt/selenium/client-combined-3.5.3-nodeps.jar:/opt/selenium/selenium-server-standalone-3.7.1.jar" de.auticon.selenium_server.Grid_SetUp
使用Grid_设置。java是:
package de.auticon.selenium_server;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
public class Grid_SetUp {
public static WebDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException{
System.setProperty("webdriver.chrome.driver","/opt/selenium/chromedriver");
String URL = "http://www.google.com";
String Node = "http://192.168.40.40:4444/wd/hub";
DesiredCapabilities cap = DesiredCapabilities.chrome();
driver = new RemoteWebDriver(new URL(Node), cap);
driver.navigate().to(URL);
Thread.sleep(5000);
driver.quit();
}
}
我得到错误:
leder@leder-VirtualBox:~/Source/SeleniumCheese/bin$ ./execute_grid.sh
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'leder-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.0-59-generic', java.version: '1.8.0_131'
Driver info: driver.version: unknown
将同一个java客户端连接到windows上的同一个java中心和节点很好!
我的电脑有问题吗
chromedriver_linux64
在ubuntu中集成?