For those of you that are using Selenium WebDriver 3 but haven’t set up a remote Selenium Server, here is a simple guide to get you going.
In this example we are just using 2 PCs.
PC1 – This is the PC with Eclipse and WebDriver 3 installed (IP: 10.0.0.37)
PC2 – This is the remote machine, which acts as both the Selenium Hub and has a Selenium Node (IP: 10.0.0.152)
So first of all we need to understand what the difference is between the Selenium Hub and the Selenium Node. The Selenium Hub (Server) acts as the controller that receives requests to execute tests on certain platforms & browsers, and then re-directs them to the appropriate Node that matches the request. So we have one Hub and we register multiple Nodes to the Hub, each Node could be a physical or virtual machine (creating a Grid of remote machines to execute tests against).
For this demo we are just using 2 physical machines, one with Eclipse/WebDriver 3 on, and the other which will take both roles of Hub and Node.
Step 1: On our remote PC, we need to download Java JRE and install it. We used JRE 1.8.0_121, downloaded from here
You can check it is installed correctly by opening a command prompt and typing java -version
Step 2: On our remote PC, we need to download the following files from SeleniumHQ :
- Selenium Server (we used selenium-server-standalone-3.3.1.jar for our demo)
- chromedriver.exe
- geckodriver.exe
- IEDriverServer.exe
Just extract these files into a folder such as documents/SelServer
Step 3: On our remote PC, add the directory that you put the selenium server and browser server files in step 2, to the system path.
On the remote machine, open the System Control Panel (Control Panel->System and Security->System) and click the Advanced system settings link on the left. On the System Properties dialog that appears, on the Advanced tab, click the Environment Variables… button.
Now select the Path variables in the system variables and click Edit… Click the New button and add the path to the directory from Step 2.
Step 4: On our remote PC, start Selenium Hub running.
Open a command window, change directory to the selenium server directory (on ours it was cd C:\Users\edgewords\Documents\SelServer)
Now start the Selenium Server, type the following and hit enter:
java -jar selenium-server-standalone-3.3.1.jar -role hub
The hub should now be running on localhost port 4444
Step 5: On our remote PC, register a Node to the Hub
Open another command prompt window and add a node to the hub:
java -jar selenium-server-standalone-3.3.1.jar -role node -hub http://localhost:4444/grid/register
We can check this has worked now by opening a web browser and going to: http://localhost:4444/grid/console
you should see the following:
Step 6: On our WebDriver 3 PC, we can now connect to the remote Selenium Hub and execute our Web Tests.
To do this, we have simply created a new project in Eclipse, Created a simple Java Class file, added our Selenium Libraries and written the code below:
And complete the details. Remember – your remote machine (Hub) IP address (highlighted in yellow in above screenshot) will be different so find out your Selenium Hub IP address on the remote machine by opening a command prompt and typing ipconfig and enter key
Now go ahead and run your web tests remotely!
Edgewords Training is a dedicated Automated Testing Tools training company. We are a Ranorex Training Partner, and provide training in Ranorex, Selenium, Cucumber, SpecFlow, HP Tools, JMeter and many other tools.
[…] blog follows on from the previous blog about how to set up Selenium Grid for WebDriver or for Ranorex Web […]
[…] a follow on to the earlier tutorial How to set up a Selenium Grid for Remote WebDriver Execution, in this tutorial we are going to set up a small Linux Virtual Machine (VM) for running remote […]
I follow your way, but it response this error:
org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: ‘3.8.1’, revision: ‘6e95a6684b’, time: ‘2017-12-01T19:05:32.194Z’
System info: host: ‘ST-DUCBM8’, ip: ‘172.30.113.165’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_144’
Driver info: driver.version: unknown
Command duration or timeout: 175 milliseconds
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
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$24(ProtocolHandshake.java:359)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:476)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:362)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:217)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:140)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at CaptureWeb.abc._3127_VER(abc.java:22)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
Build info: version: ‘3.8.1’, revision: ‘6e95a6684b’, time: ‘2017-12-01T19:05:32.194Z’
System info: host: ‘ST-DUCBM8’, ip: ‘172.30.113.165’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_144’
Driver info: driver.version: unknown
Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘ST-DUCBM8’, ip: ‘172.30.113.165’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘9.0.1’
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.ServicedSession$Factory.lambda$get$0(ServicedSession.java:208)
at org.openqa.selenium.remote.server.ServicedSession$Factory.apply(ServicedSession.java:218)
at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$11(ActiveSessionFactory.java:167)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:373)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
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.server.ActiveSessionFactory.apply(ActiveSessionFactory.java:170)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$1(NewSessionPipeline.java:44)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Collections$2.tryAdvance(Collections.java:4717)
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.server.NewSessionPipeline.lambda$createNewSession$2(NewSessionPipeline.java:47)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.DistinctOps$1$2.accept(DistinctOps.java:175)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:405)
at java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:728)
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.server.NewSessionPipeline.createNewSession(NewSessionPipeline.java:50)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:77)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:240)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Could you help me explan it? Thanks a lot
Hi, this looks like an issue with the ChromeDriver, so check:
1. You have downloaded latest ChromeDriver.exe and latest Chromw Browser
2. That they are both the same architecture (32bit or 64bit) as there are two versions of ChromeDriver.exe that are specific to the version of Chrome you are using
3. that the ChromeDriver.exe is either on your system path, or that you provide the full path in the WebDriver code.