I want to execute the parallel test with multiple Firefox browsers configured in multiple machines.
Thanks in advance.
Firefox Version: 60.0.1
Selenium Firefox Driver: 3.7.1
Geckdriver Version: v0.19.0
System.setProperty("webdriver.gecko.driver","C:\\Fm2\\Try_Browsers\\Browsers\\drivers\\geckodriver_19.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
driver.close();
I have setup grid and node in the different bat files:
HUb setup:
java -jar selenium-server-standalone-3.1.0.jar -port 4444 -role hub
Node Setup:
java -Dwebdriver.gecko.driver=./geckodriver_19.exe -jar selenium-server-standalone-3.1.0.jar -port 5557 -role node -hub http://localhost:4444/grid/register -browser "browserName=firefox, maxInstances=10, platform=ANY, seleniumProtocol=WebDriver"
System.setProperty("webdriver.gecko.driver","C:\\Fm2\\Try_Browsers\\Browsers\\drivers\\geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox");
cap.setPlatform(Platform.ANY);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.com/");
driver.close();
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{acceptInsecureCerts=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@21fa0ed7, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile@49991a02}], required capabilities = Capabilities [{}]
Build info: version: '3.1.0', revision: '86a5d70', time: '2017-02-16 07:57:44 -0800'
System info: host: 'LAPTOP-9JJJC37G', ip: '192.168.100.205', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: FirefoxDriver
Command duration or timeout: 9.72 seconds
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at Browsers.callBrowsers.sFireFox(callBrowsers.java:45)
at Browsers.callBrowsers.main(callBrowsers.java:27)
18:16:02.462 INFO - Executing: [new session: Capabilities [{acceptInsecureCerts=true, browserName=firefox, version=, platform=ANY}]])
18:16:02.488 INFO - Creating a new session for Capabilities [{acceptInsecureCerts=true, browserName=firefox, version=, platform=ANY}]
1531124162793 geckodriver INFO geckodriver 0.19.1
1531124162811 geckodriver INFO Listening on 127.0.0.1:13887
1531124163451 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\Viki\\AppData\\Local\\Temp\\rust_mozprofile.TtfJrIS5pIAk"
Unable to read VR Path Registry from C:\Users\Viki\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\Viki\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\Viki\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\Viki\AppData\Local\openvr\openvrpaths.vrpath
Unable to read VR Path Registry from C:\Users\Viki\AppData\Local\openvr\openvrpaths.vrpath
1531124171024 Marionette INFO Listening on port 50055
18:16:11.966 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '3.1.0', revision: '86a5d70', time: '2017-02-16 07:57:44 -0800'
System info: host: 'LAPTOP-9XXXC39G', ip: '122.148.110.105', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:131)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:36)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:189)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:222)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:184)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:150)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:499)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)
I see several things that could lead to your mistake. First, the version 3.1.0 is very old you should rather use 3.14.0, also the geckodriver is already with version 0.21.0.
For der latest Realeses look at here: seleniumhq
Secound, you should use the FirefoxOptions as a transfer parameter for the RemoteDriver(UrlToHub,FirefoxOptions)
and merge your DesiredCapabilities into the FirefoxOptions beforehand.
And as last problem I see, you use http://localhost:4444/wd/hub
as url. When you start the hub you will see a URL to register in the console which is not in your IP pool, you should also use this.
To start the hub you only need the commandline command:cd pathToSeleniumStandAloneServerFolder
and the start command is: java -jar selenium-standalone-<version>.jar -role hub
the port "4444" is default
Then you will see the right URL to connect the RemoteWebDriver()
. It´s look like this:
c:usr\Downloads>java -jar "selenium-server-standalone-3.14.0.jar" -role hub
12:56:40.723 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
12:56:40.725 INFO [GridLauncherV3$2.launch] - Launching Selenium Grid hub on port 4444
2018-09-07 12:56:41.063:INFO::main: Logging initialized @588ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:56:41.447 INFO [Hub.start] - Selenium Grid hub is up and running
12:56:41.448 INFO [Hub.start] - Nodes should register to http://192.168.56.1:4444/grid/register/
12:56:41.448 INFO [Hub.start] - Clients should connect to http://192.168.56.1:4444/wd/hub
The last row is the connectable URL for the RemoteWebDriver()
Now let's start the NODE with:
java -Dwebdriver.gecko.driver="PathToYourFirefoxDriver" -jar selenium-standalone-server-<versio>.jar -role node -hub http:UrlToHub:port/grid/register
Look at this example:
public WebDriver getWebDriver(final DesiredCapabilities desiredCapabilities) {
FirefoxOptions firefoxOptions;
DesiredCapabilities capabilities = new DesiredCapabilities()
capabilities.merge(desiredCapabilities);
capabilities.setPlatform(Platform.ANY);
capabilities.setBrowserName("firefox");
firefoxOptionHelper.merge(capabilities);
try {
WebDriver webDriver = new RemoteWebDriver(new URL(this.gridHubUrl), firefoxOptions);
return webDriver;
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
Hopefully it helps.