【发布时间】:2018-05-28 12:33:55
【问题描述】:
我有一个 Selenium 网格集群,包括 1 个集线器和多个节点。我想在所有节点上运行多个 Chrome 实例和多个 PhantomJS 实例。
我有以下节点配置文件:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "phantomjs",
"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": {}
}
要运行节点,我使用:
java -Dphantomjs.binary.path="ghostdriver" -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.gecko.driver=geckodriver -jar selenium-server-standalone-3.8.1.jar -role node -hub http://{myIp}:4444/grid/register/ -nodeConfig "/Users/myUser/Desktop/selenium/nodeConfig.json"
我正在成功连接到 Chrome 远程驱动程序:
String hubURL = "http://localhost:4444/wd/hub";
ChromeOptions chromeOptions = new ChromeOptions();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
RemoteWebDriver driver = new RemoteWebDriver(new URL(hubURL), capabilities);
但是,当尝试连接到 PhantomJS 远程驱动程序时,我仍然得到具有 chrome 功能的 Chrome 浏览器:
capabilities.setCapability(CapabilityType.BROWSER_NAME, BrowserType.PHANTOMJS);
capabilities.setCapability(CapabilityType.PLATFORM_NAME, Platform.MAC);
DesiredCapabilities capabilities = new DesiredCapabilities();
RemoteWebDriver driver = new RemoteWebDriver(new URL(hubURL), capabilities);
从网格控制台我可以看到所有浏览器都可用(包括 PhantomJS)grid console
我做错了什么??
编辑:
问题是在 Selenium 服务器版本 3.7.1 之前支持 PhantomJS
【问题讨论】:
-
在节点启动时发现:14:37:48.396 INFO - 找不到驱动程序类:org.openqa.selenium.phantomjs.PhantomJSDriver
-
发现在 selenium 独立服务器版本 3.8.1 上,类路径中没有 PhantomJSDriver。 3.7.1 版本一切正常
标签: java selenium selenium-webdriver selenium-grid