Error:
[TestNG] Running: C:\Users\user\AppData\Local\Temp\testng-eclipse-314942106\testng-customsuite.xml FAILED CONFIGURATION: @BeforeClass setUp org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32' System info: host: 'ksehgal', ip: '192.168.14.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_43' Driver info: driver.version: RemoteWebDriver at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153) at blogExample.TestingBot.setUp(TestingBot.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:335) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) 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.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131) at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:322) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:301) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568) ... 28 more
Console Output
SKIPPED CONFIGURATION: @AfterClass tearDown SKIPPED: testSimple =============================================== Default test Tests run: 1, Failures: 0, Skips: 1 Configuration Failures: 1, Skips: 1 =============================================== =============================================== Default suite Total tests run: 1, Failures: 0, Skips: 1 Configuration Failures: 1, Skips: 1 =============================================== [TestNG] Time taken by org.testng.reporters.JUnitReportReporter@20c1f10e: 22 ms [TestNG] Time taken by org.testng.reporters.EmailableReporter2@1b016632: 8 ms [TestNG] Time taken by org.testng.reporters.jq.Main@288051: 35 ms [TestNG] Time taken by org.testng.reporters.XMLReporter@16ba8602: 9 ms [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@1572e449: 11 ms [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 5 ms
First let us understand what this problem is, and what all I have done when I got this error. Lets start from the very beginning.
Step1: I started a Selenium hub by this command:
F:\Selenium>java -jar selenium-server-standalone-2.41.0.jar -role hub -port 1111
Step2: I made a project in Eclipse IDE with the below code.
Code Snippet used
public class TestingSeleniumGrid { private WebDriver driver; @BeforeClass public void setUp() throws Exception { DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("platform", Platform.WINDOWS); driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),capabilities); } @Test public void testSimple() throws Exception { driver.get("http://google.com"); } @AfterClass public void tearDown() throws Exception { driver.quit(); } }
Step 3: I made this program run via TestNG. And I got the above ERROR which I mentioned in the starting of this post.
RESOLUTION
Before I start discussing the fix for the above error, lets try to start from the end. This is a general tip which we all should follow while coding or working with any sort of Programming language. You should read the error stack trace very deeply and again-and-again till you get some clue from it.
Now coming back to the ERROR.
1. Check the port which you have mentioned while starting the hub , its 1111.
2. Now verify the same IP in your code its 4444.
And thats where you are wrong. You have to make sure you have entered the same port and configuration in code and console while making the set up.
You have to correct it, try changing the port in program like
driver = new RemoteWebDriver(new URL("http://localhost:1111/wd/hub"),capabilities);
OR change the command to
F:\Selenium>java -jar selenium-server-standalone-2.41.0.jar -role hub -port 4444
Hey! Thanks 🙂 Best explained article!!
LikeLiked by 1 person
Your welcome and thanks 🙂
LikeLike
Same error I got in Selenium Web Driver Coding. May I know how to resolve this issue??
LikeLike
Hi Karthik,
Kindly go through the blog, and let me know if you still face same problem.
Br,
Khyati
LikeLike
I have set the port correctly in code as well as while starting the node. Still i get this error. How to resolve it
LikeLike
Hi,
Can you kindly recheck the below points;-
Have you taken the latest selenium jar?
The path of the localhost server with port.
While running the executable jar, have you given the correct path, port, jar name?
P.S. It would be of great help if you can share your code snippet so that I can also recheck the same.
Br,
Khyati
LikeLike
Hi,
Iam trying to run selenium scripts on remote machine using selenium grid.I have written the code for 2 devices one device registered from my virtual machine and other is the remote machine my script runs on virtual machine node but not on remote machine .I see no activity on remote terminal.And in eclipse it throws similar exception as above.Iam stuck here can u help out?
LikeLike
Hi Khyati,
I am using Selenium grid to execute tests on different Virtual machines.
Have setup the node on one of the VM and treat other VMs as nodes to run tests.
To start the hub I run the startHub.bat file having the below command:
java -jar selenium-server-standalone-3.14.0.jar -role hub -port 4441 -timeout 10
So hub runs on port 4441
To start the node I run startNode.bat file having the below command:
java -Dwebdriver.chrome.driver=”%SELENIUM_HOME%\chromedriver.exe” -jar selenium-server-standalone-3.14.0.jar -role node -hub http://10.1.202.152:4441/grid/register -port 5555
So my nodes are getting registered successfully and are running at port 5555.
I could see in the hub console that my nodes are registered, but still when I run my tests one machine is not allowing it to run. Nothing happens on that machine and after few seconds I get error:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: ‘3.14.0’, revision: ‘aacccce0’, time: ‘2018-08-02T20:19:58.91Z’
System info: host: ‘NSC-JMETER01’, ip: ‘10.1.202.152’, os.name: ‘Windows Server 2016’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_161’
Driver info: driver.version: TestCaseDriver[Ljava.lang.StackTraceElement;@54a861d9
The tests are running fine on all machines, except one and I am struggling to find the solution for that.
Below is the code that I have written to run the tests
if(hostMachine.equals(“Machine1”))
nodeURL = new URL(“http://Machine1_IP:5555/wd/hub”);
else if (hostMachine.equalsIgnoreCase(“Machine2”))
nodeURL = new URL(“http://Machine2_IP:5555/wd/hub”);
else if (hostMachine.equals(“Machine3”))
nodeURL = new URL(“http://Machine3_IP:5555/wd/hub”);
BrowserType type = BrowserType.valueOf(Browser.toUpperCase());
switch (type) {
case FIREFOX:
capability = DesiredCapabilities.firefox();
driver = new RemoteWebDriver(nodeURL, capability);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
return driver;
Able to run tests on Machine 1 and Machine 2, but not sure why Machine 3 is not running the tests and giving the above error.
Can you please help me out in resolving this issue?
LikeLike
Sorry there’s a mistake in second line. Instead of node, I meant to say I have set up a hub on one VM and treat other VMS as nodes to run tests
LikeLike
You are the best… brilliantly explained!
LikeLike