I am trying to connect to a no on a Linux machine with the RemoteWebDriver, but have been unsuccessful. This is the code:
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;
}
When I run this code on the local machine, it works fine. However, when I try to run it via Grid, the following error is encountered.
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)
The first line of the exception says that it is unable to parse something, but I can't understand what?
Am I missing something? I am doing grid setup for the first time.
The problem lies in the below line
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/grid/console"),capabilities);
You are connecting to the Console servlet instead of connecting to the servlet that's responsible for honoring new sessions.
Please change the above line to
driver = new RemoteWebDriver(new URL("http://jenkins.bgr.ionidea.com:4444/wd/hub"),capabilities);
and try again. You should be fine.