top of page

selenium grid: org.openqa.selenium.remote. UnreachableBrowserException: Could not start a new sessio

  • Writer: khyati sehgal
    khyati sehgal
  • Aug 24, 2014
  • 2 min read

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
 

Happy Testing 🙂

Recent Posts

See All

Comments


bottom of page