无法连接到硒网格节点
Unable to connect to selenium grid node
我正在尝试使用 RemoteWebDriver 连接到 Linux 机器上的 no,但未成功。这是代码:
public WebDriver googlechrome(){ /*Method to start Google Chrome.*/
WebDriver driver = null;
ChromeOptions options = new ChromeOptions(); /*ChromeOptions is for firing Chrome with additional settings.*/
options.addArguments("--allow-file-access-from-files"); /*Allow Chrome to access files*/
options.addArguments("user-data-dir="+System.getProperty("user.dir")+pathChrome);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.LINUX);
try { // driver = new RemoteWebDriver(new URL("http://localhost:9515"), capabilities);
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/grid/console"),capabilities);
Chatterbox.chatterinfo("Connected to Chromedriver");
} catch (Exception e) {
Chatterbox.chattererror("Could not connect to Chromedriver. Here is the stacktrace:", e); //
e.printStackTrace();
}
return driver;
}
当我在本地机器上 运行 这段代码时,它工作正常。但是,当我尝试通过 Grid 运行 时,遇到以下错误。
org.openqa.selenium.WebDriverException: Unable to parse remote
response: Grid Console.busy {
opacity : 0.4;filter: alpha(opacity=40);}
Selenium
Grid Console
v.3.1.0
https://github.com/SeleniumHQ/selenium/wiki/Grid2'>HelpDefaultRemoteProxy (version : 3.4.0)id : http://proxyhost:port, OS : LINUXBrowsersConfiguration
WebDriverv:
v:
browserTimeout: 0
debug:
false
help: false
port: 5555
role:
node
timeout: 1800
cleanUpCycle: 5000
host:
10.91.3.204
maxSession: 5
capabilities: Capabilities [{seleniumProtocol=WebDriver, browserName=firefox, maxInstances=5,
platform=LINUX}]
capabilities: Capabilities
[{seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5,
platform=LINUX}]
downPollingLimit: 2
hub:
http://jenkins host:jenkins port
id:
http://node ip:node port
hubHost:
jenkins.bgr.ionidea.com
hubPort: 4444
nodePolling:
5000
nodeStatusCheckTimeout: 5000
proxy:
org.openqa.grid.selenium.proxy.DefaultRemoteProxy
register:
true
registerCycle: 5000
remoteHost:
http://node ip:node port
unregisterIfStillDownAfter:
60000
view
config Build info: version: '3.4.0', revision:
'unknown', time: 'unknown' System info: host:
'Brindalas-MacBook-Air-2.local', ip: '10.91.17.123', os.name: 'Mac OS
X', os.arch: 'x86_64', os.version: '10.11.5', java.version:
'1.8.0_121' Driver info: driver.version: RemoteWebDriver at
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:353)
at
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174)
at core.drivers.Browsers.googlechrome(Browsers.java:45) at
core.drivers.Selenium.startBrowser(Selenium.java:18) at
tryFireBrowser.fireBrowser(tryFireBrowser.java:13) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661) at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869) at
org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193) at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744) at
org.testng.TestRunner.run(TestRunner.java:602) at
org.testng.SuiteRunner.runTest(SuiteRunner.java:380) at
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375) at
org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) at
org.testng.SuiteRunner.run(SuiteRunner.java:289) at
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at
org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) at
org.testng.TestNG.runSuitesLocally(TestNG.java:1226) at
org.testng.TestNG.runSuites(TestNG.java:1144) at
org.testng.TestNG.run(TestNG.java:1115) at
org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72) at
org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
异常的第一行说它无法解析某些东西,但我不明白什么?
我错过了什么吗?我是第一次做网格设置。
问题出在下面一行
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/grid/console"),capabilities);
您正在连接到控制台 servlet,而不是连接到负责处理新会话的 servlet。
请将上面一行改为
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/wd/hub"),capabilities);
然后重试。你应该没事的。
我正在尝试使用 RemoteWebDriver 连接到 Linux 机器上的 no,但未成功。这是代码:
public WebDriver googlechrome(){ /*Method to start Google Chrome.*/
WebDriver driver = null;
ChromeOptions options = new ChromeOptions(); /*ChromeOptions is for firing Chrome with additional settings.*/
options.addArguments("--allow-file-access-from-files"); /*Allow Chrome to access files*/
options.addArguments("user-data-dir="+System.getProperty("user.dir")+pathChrome);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setBrowserName("chrome");
capabilities.setPlatform(Platform.LINUX);
try { // driver = new RemoteWebDriver(new URL("http://localhost:9515"), capabilities);
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/grid/console"),capabilities);
Chatterbox.chatterinfo("Connected to Chromedriver");
} catch (Exception e) {
Chatterbox.chattererror("Could not connect to Chromedriver. Here is the stacktrace:", e); //
e.printStackTrace();
}
return driver;
}
当我在本地机器上 运行 这段代码时,它工作正常。但是,当我尝试通过 Grid 运行 时,遇到以下错误。
org.openqa.selenium.WebDriverException: Unable to parse remote response: Grid Console.busy { opacity : 0.4;filter: alpha(opacity=40);}
Selenium
Grid Console v.3.1.0
https://github.com/SeleniumHQ/selenium/wiki/Grid2'>HelpDefaultRemoteProxy (version : 3.4.0)id : http://proxyhost:port, OS : LINUXBrowsersConfiguration
WebDriverv:
v:
browserTimeout: 0
debug: false
help: false
port: 5555
role: node
timeout: 1800
cleanUpCycle: 5000
host: 10.91.3.204
maxSession: 5
capabilities: Capabilities [{seleniumProtocol=WebDriver, browserName=firefox, maxInstances=5, platform=LINUX}]
capabilities: Capabilities [{seleniumProtocol=WebDriver, browserName=chrome, maxInstances=5, platform=LINUX}]
downPollingLimit: 2
hub: http://jenkins host:jenkins port
id: http://node ip:node port
hubHost: jenkins.bgr.ionidea.com
hubPort: 4444
nodePolling: 5000
nodeStatusCheckTimeout: 5000
proxy: org.openqa.grid.selenium.proxy.DefaultRemoteProxy
register: true
registerCycle: 5000
remoteHost: http://node ip:node port
unregisterIfStillDownAfter: 60000
view config Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'Brindalas-MacBook-Air-2.local', ip: '10.91.17.123', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.5', java.version: '1.8.0_121' Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:353) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174) at core.drivers.Browsers.googlechrome(Browsers.java:45) at core.drivers.Selenium.startBrowser(Selenium.java:18) at tryFireBrowser.fireBrowser(tryFireBrowser.java:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) at org.testng.internal.Invoker.invokeMethod(Invoker.java:661) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.privateRun(TestRunner.java:744) at org.testng.TestRunner.run(TestRunner.java:602) at org.testng.SuiteRunner.runTest(SuiteRunner.java:380) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) at org.testng.SuiteRunner.run(SuiteRunner.java:289) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) at org.testng.TestNG.runSuitesLocally(TestNG.java:1226) at org.testng.TestNG.runSuites(TestNG.java:1144) at org.testng.TestNG.run(TestNG.java:1115) at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
异常的第一行说它无法解析某些东西,但我不明白什么?
我错过了什么吗?我是第一次做网格设置。
问题出在下面一行
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/grid/console"),capabilities);
您正在连接到控制台 servlet,而不是连接到负责处理新会话的 servlet。
请将上面一行改为
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/wd/hub"),capabilities);
然后重试。你应该没事的。