Unreachablebrowserexception error communicating with the remote browser it may have died

Here is my error log: Apr 12, 2014 3:27:46 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: I/O exception (java.net.SocketException) caught when connecting to the target host:

Here is my error log:

Apr 12, 2014 3:27:46 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Permission denied: connect
Apr 12, 2014 3:27:46 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: Retrying connect
Apr 12, 2014 3:27:46 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Permission denied: connect
Apr 12, 2014 3:27:46 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: Retrying connect
Apr 12, 2014 3:27:46 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Permission denied: connect
Apr 12, 2014 3:27:46 AM org.apache.http.impl.client.DefaultRequestDirector tryConnect
INFO: Retrying connect
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'prgi-PC', ip: '192.168.1.9', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
    at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:187)
    at org.openqa.selenium.remote.RemoteWebElement.findElementsByTagName(RemoteWebElement.java:264)
    at org.openqa.selenium.By$ByTagName.findElements(By.java:323)
    at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:163)
    at com.sai.kiran.Test.main(Test.java:155)
Caused by: java.net.SocketException: Permission denied: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:83)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    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.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:165)
    at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:362)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)
    ... 6 more

CODE:

FirefoxProfile profile = new FirefoxProfile();

String path="C:\Users\prgi\Downloads\listShack";
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", path);

profile.setPreference("browser.download.manager.alertOnEXEOpen", false);

profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/msword,application/csv,text/csv,image/png ,image/jpeg");

profile.setPreference("browser.download.manager.showWhenStarting",
false);

profile.setPreference("browser.download.manager.focusWhenStarting",
false);
//profile.setPreference("browser.download.useDownloadDir",true);
profile.setPreference("browser.helperApps.alwaysAsk.force",
false);

profile.setPreference("browser.download.manager.alertOnEXEOpen", false);

profile.setPreference("browser.download.manager.closeWhenDone", false);

profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.useWindow",
false);

profile.setPreference("browser.download.manager.showWhenStarting",false);

profile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting",
false);

profile.setPreference("pdfjs.disabled", true);

WebDriver driver = new FirefoxDriver(profile);

and from here I am managing my elements..

note: It worked two days continuously 24/7 and today I am getting this error frequently.

I am also facing the same issue with Firefox browser.Here is the error i am getting:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: ‘2.53.1’, revision: ‘a36b8b1’, time: ‘2016-06-30 17:37:03’
System info: host: ‘DK005898’, ip: ‘10.128.2.1’, os.name: ‘Windows 10’, os.arch: ‘x86’, os.version: ‘10.0’, java.version: ‘1.8.0_151’
Driver info: driver.version: RemoteWebDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.0.2, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 7abcb33c-9c4b-4bdb-996c-25d93e2e30f6
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:526)
at FirewallTest.quitDriver(FirewallTest.java:43)
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:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:731)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:877)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1201)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:776)
at org.testng.TestRunner.run(TestRunner.java:634)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:425)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:420)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:385)
at org.testng.SuiteRunner.run(SuiteRunner.java:334)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1318)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1243)
at org.testng.TestNG.runSuites(TestNG.java:1161)
at org.testng.TestNG.run(TestNG.java:1129)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 88; received: 0
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:180)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:200)
at org.apache.http.impl.io.ContentLengthInputStream.close(ContentLengthInputStream.java:103)
at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:140)
at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228)
at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:174)
at org.apache.http.util.EntityUtils.consume(EntityUtils.java:88)
at org.openqa.selenium.remote.internal.ApacheHttpClient.createResponse(ApacheHttpClient.java:113)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:94)
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)
… 30 more

The issue occurs only when i am connected to my office network, but verified this with chromedriver and it works fine on office network as well. So not able to figure out what the root cause of the issue is.

Any help around this would be highly appreciated.

This page is a summary of 3 different fixes for 3 different ways how to get UnreachableBrowserException-s while using WebDrivers

1. Caused by: java.net.SocketException: Software caused connection abort: recv failed

To fix this issue just replace usage of PhantomJSDriver with following FixedPhantomJSDriver:

public class FixedPhantomJSDriver extends PhantomJSDriver {

    private final int retryCount = 2;

    public FixedPhantomJSDriver() {
    }

    public FixedPhantomJSDriver(Capabilities desiredCapabilities) {
        super(desiredCapabilities);
    }

    public FixedPhantomJSDriver(PhantomJSDriverService service, Capabilities desiredCapabilities) {
        super(service, desiredCapabilities);
    }

    @Override
    protected Response execute(String driverCommand, Map<String, ?> parameters) {
        int retryAttempt = 0;

        while (true) {
            try {

                return super.execute(driverCommand, parameters);

            } catch (UnreachableBrowserException e) {
                retryAttempt++;
                if (retryAttempt > retryCount) {
                    throw e;
                }
            }
        }
    }
}

So in summary:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.

caused by:

Caused by: java.net.SocketException: Software caused connection abort: recv failed

(the recv failed is important)

happens (from my investigations) when connection is closed prematurely. In our case it seemed to be caused by ssl certificate handling in java (I’m still investigating this) and is extremely random. Luckily all http traffic is handled by the execute method. So by overriding it and adding simple retry functionality you provide a working workaround solution (it helped us on our project as we never had a failing/flaky tests again).

Although this is a specific implementation for PhantomJS driver, the same approach should work for other drivers as well.

2. Caused by: java.net.SocketTimeoutException: Read timed out

But there is still chance that you have different symptoms and your browser just hangs for some time until it throws:

Caused by: java.net.SocketTimeoutException: Read timed out

If you’re working on a Windows machine, the chances are that you’ve reached limit of possible open connections. This normally happens, because Selenium creates a lot of connections and Windows keeps them opened/cached even when java triggered a close connection command.
To fix this issue you need to change Windows registry values under:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters

you need to set/create two DWORD values:

MaxUserPort = 32768
TcpTimedWaitDelay = 30

MaxUserPort will increase the limit of possible open connections (you can select any value between 5000-65534, the higher the better). TcpTimedWaitDelay makes sure that windows will close stale connections (already closed by java) after 30 seconds (can’t be set to lower, but without setting this the default value is 4 minutes !!!). In most cases this should fix your «hang» issue.

3. When your test still hangs for 3 hours until it fails

Unfortunately there is still a small chance that you have issues where your test will get stuck for 3 hours !!! The reason for this is that the HttpClientFactory in selenium has hardcoded socket timeout to 3 hours, and although there is a proposed fix to the selenium core code, until it will be accepted there is no way how to change it using normal means.
For those who unfortunatelly must bear the pain, here is how you use my hacky, but working workaround to this problem:

public class FixExample {

    public static void main(String[] args) {
    
        // this is my custom workaround

        HttpParamsSetter.setSoTimeout(60 * 1000); // set socket timeout to 1 minute
        
        // and here goes your custom code

        WebDriver driver = new PhantomJSDriver();
        
        ...

        driver.quit();
    }
}

Here you can find the code that does the magic (this works because fields HttpCommandExecutor.httpClientFactory and HttpClientFactory.client are static fields that are initialized only once):

import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.remote.internal.HttpClientFactory;
import java.lang.reflect.Field;

public class HttpParamsSetter {

    @SuppressWarnings("deprecation")
    public static void setSoTimeout(int soTimeout) {
        HttpClientFactory factory = getStaticValue(HttpCommandExecutor.class, "httpClientFactory");
        if (factory == null) {
            factory = new HttpClientFactory();
        }

        DefaultHttpClient httpClient = (DefaultHttpClient) factory.getHttpClient();
        HttpParams params = httpClient.getParams();
        HttpConnectionParams.setSoTimeout(params, soTimeout);
        httpClient.setParams(params);

        setStaticValue(HttpCommandExecutor.class, "httpClientFactory", factory);
    }

    private static <T> T getStaticValue(Class<?> aClass, String fieldName) {
        Field field = null;
        Boolean isAccessible = null;
        try {
            field = aClass.getDeclaredField(fieldName);
            isAccessible = field.isAccessible();
            field.setAccessible(true);

            return (T) field.get(null);

        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } finally {
            if (field != null && isAccessible != null) {
                field.setAccessible(isAccessible);
            }
        }
    }

    private static void setStaticValue(Class<HttpCommandExecutor> aClass, String fieldName, Object value) {
        Field field = null;
        Boolean isAccessible = null;
        try {
            field = aClass.getDeclaredField(fieldName);
            isAccessible = field.isAccessible();
            field.setAccessible(true);

            field.set(null, value);

        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } finally {
            if (field != null && isAccessible != null) {
                field.setAccessible(isAccessible);
            }
        }
    }
}

I am running selenium scripts on EC2 instance in headless mode. The scripts run multiple parallel chrome browsers. So 1 out of 3 times I get the following error —

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'new-selenium-jenkins', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-1081-aws', java.version: '1.8.0_342'
Driver info: driver.version: RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 98.0.4758.102, chrome: {chromedriverVersion: 98.0.4758.102 (273bf7ac8c90..., userDataDir: /tmp/.com.google.Chrome.6KFODw}, goog:chromeOptions: {debuggerAddress: localhost:40821}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 68fbeff253e6c1d70f858edc8aa8d386
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:609)
    at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:452)
    at com.coda.object.Driversetup.closeSession(Driversetup.java:65)
    at com.coda.testcases.Basesetup.teardown(Basesetup.java:17)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    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:750)
Caused by: java.lang.RuntimeException: java.util.concurrent.TimeoutException
    at org.openqa.selenium.net.UrlChecker.waitUntilUnavailable(UrlChecker.java:145)
    at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:224)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:95)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    ... 23 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(FutureTask.java:205)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
    at org.openqa.selenium.net.UrlChecker.waitUntilUnavailable(UrlChecker.java:115)
    ... 26 more
... Removed 13 stack frames

Is this issue because of the system resources being used to their full extent? I observed all the 8 cores of the CPU were showing 100% occupied and memory usage is around 20GB out of 32GB.

Hi,
I am using Selenoid 1.10.3
Java client 3.14.0
JVM 1.8
Tested on Chrome 62,77,90

Daily I run hundred parallel test without issues invoking with remotedriver my test on a selenoid remote grid.
Sometimes my application raise this error: org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died
And Caused by: java.net.SocketException: Connection timed out (Read failed)

This issue occurs when I invoke this part of code (but sometimes not always):
JavascriptExecutor javascript = (JavascriptExecutor) this.localDriver; statusValue = (String) javascript.executeScript("return document.readyState"); log.info("Status javascript:" + statusValue);

Seems an hang on network level when execute javascript.executeScript(«return document.readyState»);
After 10 minutes it raise the exception below and after the test continue without problem because the container is not died.
In the meanwhile during the 10 minute if I send a get/post request with postman to selenoid for that session for example to retrieve screenshot, works fine.

FULL STACK:
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died. Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z' System info: host: 'atfprocessor-163-pqg9s', ip: '10.252.53.245', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1062.1.2.el7.x86_64', java.version: '1.8.0_242' Driver info: driver.version: RemoteWebDriver Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 77.0.3865.40 (f484704e052e0..., userDataDir: /tmp/.com.google.Chrome.QvDEQY}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:38756}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 77.0.3865.75, webStorageEnabled: true} Session ID: e2d9d9628c43d72234fa4ad6a0e95874 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569) ~[selenium-remote-driver-3.14.0.jar:?] at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:485) ~[selenium-remote-driver-3.14.0.jar:?]
and after as latest exception:
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_242] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_242] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242] Caused by: java.net.SocketException: Connection timed out (Read failed) at java.net.SocketInputStream.socketRead0(Native Method) ~[?:1.8.0_242] at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[?:1.8.0_242] at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[?:1.8.0_242] at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:1.8.0_242] at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[httpcore-4.4.6.jar:4.4.6] at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[httpcore-4.4.6.jar:4.4.6] at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282) ~[httpcore-4.4.6.jar:4.4.6] at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.6.jar:4.4.6] at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) ~[httpcore-4.4.6.jar:4.4.6] at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.6.jar:4.4.6] at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.6.jar:4.4.6] at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.3.jar:4.5.3] at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:155) ~[selenium-remote-driver-3.14.0.jar:?] at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:97) ~[selenium-remote-driver-3.14.0.jar:?] at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:155) ~[selenium-remote-driver-3.14.0.jar:?] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) ~[selenium-remote-driver-3.14.0.jar:?] ... 12 more

UnreachableBrowserException: Error communicating with the remote browser. It may have died !

So this is something I learnt the hardway , all of a sudden the selenium scripts throw an error:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.

I am not sure which one might work for you but I am sure things that will not work:

1. Upgarding firefox or any browser

2. Adding/Deleting the jar files

3. Changing the driver to instantiate the browser

4. Killing or trying to find orphan processes
 

Solutions:

  • Cherck for compatibilty of browser with selenium
  • Make sure that there are no warnings in your code 
  • Open the browser (in my case firefox)

    Go to the address bar and type about:config
    Right-click and create a new boolean value
    and name its as extensions.checkCompatibility.19.0
    Set this value to false
    restart the browser
  • Make sure you update the objects properties 

Finally also be sure that you check different websites and objects!

Happy Coding…

Popular posts from this blog

Trim / Remove spaces in Xpath?

Image

If you are wondering how you can trim the spaces in your xpath, this is how: The normalize-space function strips leading and trailing white-space from a string, replaces sequences of white-space characters by a single space, and returns the resulting string. Example : Which one is better? //td[starts-with(normalize-space(),’Text to Trim’)] //td[starts-with(normalize-space(text()),’ Text to Trim ‘)] The second option is better as it targets at the specific nodes More string functions in XPATH: Functions Description starts-with( string1 ,  string2 ) Returns true if the first string starts with the second string. contains( string1 ,  string2 ) Returns true if the first string contains the second string. substring( string offset length ) Returns a section of the string. The section starts at  offset (which is a number), and is as long as the value provided at  length. substring-before( string1 ,  string2 ) Returns the part of  string1  up unti

Three amigios | CI — CD — Test Automation

Image

Architecting for CI/CD — DZone DevOps Learn how companies must change their software architecture to fully take advantage of continuous integration and delivery and implement effective DevOps.

QTP Test Automation Framework Architecture

Image

Here is a mindmap that I had created some time back on a hybrid test automation framework, this gives a nice idea of the functionalities a framework might want to incorporate.

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_29'
Driver info: driver.version: RemoteWebDriver

This is the error message which gets displayed when I am trying to run my scripts? Scenario :My one java file has login function and second has creation of a new Account after login Kindly advise.

Login.java:

public class LoginPage
{ 

    public static WebDriver driver;  

    public static final LoginPage login = new LoginPage(new FirefoxDriver()); 

    public LoginPage(WebDriver driver)
    {
        LoginPage.driver = driver;
    } 

    public static void loginAs(String username, String password)
    {
        DesiredCapabilities ieCapabilities = DesiredCapabilities.firefox();

        ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); 

        Proxy proxy = new Proxy(); 

        proxy.setProxyAutoconfigUrl("http://www.config.barclays.co.uk:9000/");

        driver.close();

        ieCapabilities. setCapability(CapabilityType.PROXY, proxy); 

        FirefoxDriver driver = new FirefoxDriver(ieCapabilities);

        driver.get("https://login.salesforce.com"); 

        driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);

        //Login to Salesforce Application
        try
        {
            driver.findElement(By.id("username")).sendKeys(username);

            driver.findElement(By.id("password")).sendKeys(password);   

            driver.findElement(By.id("Login")).click();

            driver.manage().timeouts().implicitlyWait(75, TimeUnit.SECONDS);

        }
        catch(Exception e1)
        {

            System.out.println(e1 +"Your login attempt has failed. The username or password may be incorrect, or your location or login time may be restricted. Please contact the administrator at your company for help.");
        }

    }

    public static void main(String[] args)
    {
        login.loginAs("[email protected]", "Pa$$word");
    }
}

Second File where I am trying to click on Opportunity tab of my Sales force application : CreatOpportunity.java these lines are under my main argument

LoginPage.login.loginAs("username", "password");

LoginPage.login.driver.findElement(By.id("Opportunity_Tab")).click();

Running my second file allows me to launch my application but does not detect the click on the Opprtunity tab and throws me the error mentioned above


just give a try with by putting below line after login.

driver.switchTo.defaultContent();

try with below code.

public class LoginPage {
    public static WebDriver driver;  

    public LoginPage()
    {
         DesiredCapabilities ieCapabilities = DesiredCapabilities.firefox();
         ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
         Proxy proxy = new Proxy();
         proxy.setProxyAutoconfigUrl("http://www.config.barclays.co.uk:9000/");
         ieCapabilities. setCapability(CapabilityType.PROXY, proxy);
         LoginPage.driver = new FirefoxDriver(ieCapabilities);
         driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
    } 

    public static void loginAs(String username, String password) {  

        driver.get("https://login.salesforce.com");
        //Login to Salesforce Application
        try
            {
            driver.findElement(By.id("username")).sendKeys(username);
            driver.findElement(By.id("password")).sendKeys(password);
            driver.findElement(By.id("Login")).click();
            driver.manage().timeouts().implicitlyWait(75, TimeUnit.SECONDS);
            }
        catch(Exception e1) {

            System.out.println(e1 +"Your login attempt has failed. The username or password may be incorrect, or your location or login time may be restricted. Please contact the administrator at your company for help.");
        }
}

    public static void main(String[] args)
    {
        LoginPage login = new LoginPage();
        login.loginAs("[email protected]", "Pa$$word");
        FileTwo.clickOpportunity(driver);
    }

}

FileTwo

public class FileTwo
{
 public static void clickOpportunity(WebDriver driver)
 throws Exception
 {
      driver.findElement(By.id("Opportunity_Tab")).click();
 }
}

Понравилась статья? Поделить с друзьями:
  • Unrar dll вернул код ошибки 11
  • Update error смс центр
  • Update error tower of fantasy
  • Unrecoverable playback error unsupported stream format 176400 hz 32 bit 2 channels
  • Update error 80240037