如何在java中启动远程_如何使用Java中的Selenium Grid启动Chrome(普通和无痕模式)并在远程PC(节点)中打开URL?...

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": {}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值