Chrome not reachable Selenium WebDriver error - selenium-webdriver

I am facing this issue; I know this question is already present and I have tried the solutions mentioned hence asking this with my configurations and code.
Earlier the scripts were running but now they aren't So i tried making a basic open browser script.
Latest Version of Selenium WebDriver : http://selenium-release.storage.googleapis.com/3.5/selenium-java-3.5.0.zip
Latest Version on ChromeDriver : http://chromedriver.storage.googleapis.com/index.html?path=2.31/
Basic Open browser code:
package Trial;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Trial_Class {
public static void main(String args[]){
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.youtube.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
}
But still I am getting the below error:
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 43967
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.81 seconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'SWATI', ip: '192.168.0.5', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_121'
Driver info: driver.version: ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
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:360)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:363)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:137)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:254)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
at Trial.Trial_Class.main(Trial_Class.java:11)
Thanks in Advance.

Your chromedriver is starting just fine:
"Starting ChromeDriver 2.31.488763
(092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 43967"
The problem is the browser itself is not responding. So I have two ideas:
1) Your browser is not installed in the default location; If this is the case, add this to your code:
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
WebDriver driver = new ChromeDriver(capabilities);
2) Your browser is latest version, but your chromedriver isn't - current is 2.33

I found that chromedriver had hard time to resolve localhost and during that it printed
Timed out connecting to Chrome, retrying...
It first tried to connect via ipv6 and then I guess fall back to ipv4. So what worked for me was to change the priority of "localhosts" this way
The only piece you should need to do is change the priority:
Open RegEdit, navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tcpip6\Parameters
Create DisabledComponents DWORD registry value, set its value to 20
(Hexadecimal). src

you have to set the
setProperty(String key, String path)
here "key" is your "webdriver.chrome.driver" and "path" is "path where your driver is stored". Use single forward slash "/" in path.
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.youtube.com");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Above code is work well in Selenium jar 3.5.0. Hope works fine in your system too.

Related

Selenium 4.6.0 - SessionNotCreatedException when trying to run a test in standalone mode

I'm using Selenium 4.6.0 and trying to create a simple test to run and below is the code I'm using
private static WebDriver driver;
dc.setBrowserName("chrome");
driver=new RemoteWebDriver(new URL(remoteURL), dc);
Chrome driver version: 107.0.5304.62
Chrome version: 107.0.5304.122
Chrome driver is compatible with the browser version. I have used both http://localhost:4444 and the http://192...**:4444 but both run into the same exception
Exception
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Host info: host: 'RAM', ip: '192.***.**.***'
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_333'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome}], desiredCapabilities=Capabilities {browserName: chrome}}]
Capabilities {}
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at framework.maincontroller.MainController.createDriver(MainController.java:2472)
at framework.maincontroller.MainController.setUp(MainController.java:2851)
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:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)
at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:700)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
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:750)
Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableMap;
at org.openqa.selenium.chrome.AddHasCasting.getAdditionalCommands(AddHasCasting.java:38)
at org.openqa.selenium.remote.Dialect.lambda$bindAdditionalCommands$1(Dialect.java:80)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.openqa.selenium.remote.Dialect.bindAdditionalCommands(Dialect.java:79)
at org.openqa.selenium.remote.Dialect.access$100(Dialect.java:29)
at org.openqa.selenium.remote.Dialect$2.getCommandCodec(Dialect.java:54)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at
org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:541)
... 24 more

Appium_Error : Returned value cannot be converted to WebElement with Xcode 10.0

Getting the error 'Returned value cannot be converted to WebElement'
Xcode Version : 10.0
Appium Server Version : 1.9.1 / 1.13.0
Appium Client Version : 6.1.0 / 7.0.0
Selenium Version : 3.9.1 / 3.14.0
IOS Simulator Version : 11.4
Have tried with different versions as below:
Appium Server version : from 1.7.2 to 1.14.2 beta
Appium Client version : 5.0.4 to 7.0.0
Also tried to include implicit wait and explicit waits as well. No luck :(
Appium Logs Client Side as below:
[RemoteTestNG] detected TestNG version 6.11.0
Jul 01, 2019 10:34:30 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
FAILED CONFIGURATION: #BeforeSuite setupDriver
org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {element-6066-11e4-a52e-4f735466cecf=2B000000-0000-0000-777A-000000000000, ELEMENT=2B000000-0000-0000-777A-000000000000}
Build info: version: '3.5.2', revision: '10229a9', time: '2017-08-21T17:29:55.15Z'
System info: host: 'Bindacharyas-MacBook-Pro.local', ip: 'fe80:0:0:0:c4b:5bdc:c1c1:72f2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '1.8.0_211'
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:421)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1)
at io.appium.java_client.FindsByAccessibilityId.findElementByAccessibilityId(FindsByAccessibilityId.java:31)
at com.noon.ui.tests.sanitySuites.TestIOSAnother.prepareIOSForAppium(TestIOSAnother.java:103)
at com.noon.ui.tests.sanitySuites.TestIOSAnother.setupDriver(TestIOSAnother.java:58)
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.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:326)
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.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:419)
... 25 more
Few Lines of Code as below:
capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6s Plus");
capabilities.setCapability("wdaStartupRetries", 5);
capabilities.setCapability("autoAcceptAlerts", true);
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("newCommandTimeout", 250);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.4");
capabilities.setCapability(MobileCapabilityType.APP, "/Users/bindacharyaj/Documents/Simulator/k12App-ios.app");
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.UDID, "777EA4A8-0C82-485D-8347-8EF3527B135A");
capabilities.setCapability("bundleId", "com.noonEdu.k12App");
capabilities.setCapability("updatedWDABundleId", "com.facebook.wda.lib");
capabilities.setCapability("wdaLocalPort", 8101);
driver = new IOSDriver<MobileElement>(url, capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println(driver.getContext());
driver.context("NATIVE_APP");
}
// 6
#Test(enabled = true)
public void myFirstTest() throws InterruptedException {
Thread.sleep(000);
System.out.println("Test Started");
((WebElement) driver.findElement(By.xpath("//XCUIElementTypeStaticText[#name='السعودية']"))).click();
System.out.println("Click -1");
Thread.sleep(2000);
Appium launches the app but not able to click on any of the native elements.
Any help would be appreciated!!
Thanks in advance... !!!!

Capabilities error after using selenium grid and Webdriver manager

I have been using [webdriver manager][1] for local executions, it has been outstanding, however right now I'm trying to use a selenium grid and I would like to use the same approach but I'm getting some errors related to capabilities.
The hub and node are localhost, these are the details of my implementation:
I'm starting the hub with this line:
start cmd /k java -jar selenium-server-standalone-3.5.0.jar -role hub -port 4443
I'm starting the node with this line
start cmd /k java -jar selenium-server-standalone-3.5.0.jar -port 5556 -role node -hub http://localhost:4443/grid/register
This is the configuration that I'm using for the browsers, the problem is with chrome, I haven't tested the other ones yet.
public WebDriver cbt(String browser, String methodName) throws Exception{
WebDriver driver;
DesiredCapabilities caps;
//Check if parameter passed from TestNG is 'firefox'
if(browser.equalsIgnoreCase("firefox"))
{
caps = DesiredCapabilities.firefox();
caps.setCapability("platform", "Windows 10");
caps.setCapability("version", "53.0");
caps.setCapability("name", methodName);
}
//Check if parameter passed as 'chrome'
else if(browser.equalsIgnoreCase("chrome"))
{
caps = DesiredCapabilities.chrome();
}
else if(browser.equalsIgnoreCase("ie")){
caps = DesiredCapabilities.edge();
caps.setCapability("platform", "Windows 10");
caps.setCapability("version", "14.14393");
caps.setCapability("name", methodName);
}
else{
//If no browser passed throw exception
throw new Exception("Browser is not correct");
}
String hub = "http://localhost:4443/wd/hub";
driver = new RemoteWebDriver(new URL(hub), caps);
return driver;
}
These are the errors that I'm getting
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
System info: host: 'NEYMAR', ip: '169.254.112.118', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:158)
at com.gnow.gnow.Utils.CommonConfiguration.cbt(CommonConfiguration.java:213)
at com.gnow.gnow.Test.Test.setUp(Test.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:217)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:590)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
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:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
Thanks in advance
[1]: https://github.com/bonigarcia/webdrivermanager
First thing i would suggest is that you upgrade your selenium version to Selenium 3.5.1
There was a bug in Selenium 3.3.1 wherein the actual error wouldn't be passed on to the end-user, and your stacktrace seems to suggest that it's perhaps due to that bug is why you aren't able to see the real problem. This bug was fixed in 3.4.0
Once you upgrade to Selenium 3.5.1 in your client side, you should immediately see the problem.
Since you mentioned Chrome, am guessing that it is perhaps due to the fact that your chromedriver is not available in the PATH.
You might want to take a look at this tutorial I wrote up on Grid, which tells you the set of things that is required to get the Grid up and running. I have included a lot of other information about the Grid as well in there.

selenium geckodriver error with firefox

While launching firefox browserin eclipse i am getting an error as mentioned below Usage:
E:\new gecko\geckodriver.exe [OPTIONS]
E:\new gecko\geckodriver.exe: Unknown option --port=30415
Exception in thread "main" org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:30415 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800'
System info: host: 'KIREETI-PC', ip: '192.168.43.138', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:125)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:121)
at sriram.main(sriram.java:17)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:30415 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:158)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:142)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:88)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:296)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:113)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
... 22 more
Instead of using driver of specific browser, you can use "Webdrivermanager" plugin in maven, so it will resolve most of problems related to browser and its instance.
Even this help me lot to overcome browser related problems.
I tried using all the latest versions of driver executable file(geckodriver.exe), Selenium server standalone jar (3.14.0) and Firefox browser. I was not facing any issues.

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException:Could not start a new session

I just started to learn Selenium WebDriver. Could you all help me to resolve below problem.
I simply want to open the web-site(I am able to open browser successfully but navigation got failed )
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class webdriverdemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
//Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch website
driver.navigate().to("http://www.calculator.net/");
//Maximize the browser
driver.manage().window().maximize();
}
}
I found below errors :
Exception in thread "main"
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.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'WIN-EHSO6G1D9KD', ip: '192.168.13.2', os.name: 'Windows Server 2012', os.arch: 'amd64', os.version: '6.2',
java.version: '1.8.0_91'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120)
at webdriverdemo.main(webdriverdemo.java:13)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:380)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 7 more
Firefox version 47.0.6
Platform Win2k12 r2
Seems like there is some issue with creating session with Firefox.
Try the following code and test using Chrome browser.
You need to download the executable driver from: https://sites.google.com/a/chromium.org/chromedriver/downloads
public static void main(String[] args){
System.setProperty("webdriver.chrome.driver","/path/to/chromedriver");
WebDriver driver = new ChromeDriver();
driver = new ChromeDriver();
//Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch website
driver.get("http://www.calculator.net/");
//Maximize the browser
driver.manage().window().maximize();
}

Resources