2 - 在 “Icognito模式” 是Chrome浏览器的能力 - 它被设定为这样的:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("-incognito");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
// For local usage
driver = new ChromeDriver(capabilities);
// For HUB usage
driver = new RemoteWebDriver(new URL("hub url here"), capabilities);
3 - 您需要使用反斜杠指向系统属性指向您的博士艾弗执行,还需要逃避那些额外backslahes,如果你使用的是Java:
System.setProperty("webdriver.chrome.driver", "C:\\pathto\\my\\chromedriver.exe");
4 - 对于HUB使用,每个节点需要chromedriver。只要把它放在同一文件夹中的硒服务器独立-3.3.1.jar并开始这样的节点:
java -Dwebdriver.chrome.driver="./chromedriver.exe" -jar selenium-server-standalone-3.3.1.jar -role node -nodeConfig nodeConfig.json
当然,你需要一个nodeConfig允许的Chrome浏览器。这里是一个例子:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}