selenium icon indicating copy to clipboard operation
selenium copied to clipboard

UnreachableBrowserException when implicitlyWait > 60s

Open mmajcherczyk opened this issue 6 years ago • 8 comments

🐛 Bug Report

UnreachableBrowserException instead of NoSuchElementException when implicitlyWait greater than 60s

To Reproduce

run this test(selenium 4.0.0-alpha-5)

@Test
public void test() {
    WebDriverManager.chromedriver().setup();
    ChromeOptions options = new ChromeOptions();
    WebDriver driver = new ChromeDriver(options);
    driver.manage().timeouts().implicitlyWait(61, TimeUnit.SECONDS);
    driver.get("https://google.com");
    driver.findElement(By.id("identifierId"));
    driver.quit();
}

I get an error message:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '4.0.0-alpha-5', revision: 'b3a0d621cc'
System info: host: 'MacBook-Pro-2', ip: 'fe80:0:0:0:31:8ff8:ab39:5031%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.3', java.version: '1.8.0_191'
Driver info: driver.version: RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 81.0.4044.113, chrome: {chromedriverVersion: 80.0.3987.106 (f68069574609..., userDataDir: /var/folders/hd/yrwc8tsx1tv...}, goog:chromeOptions: {debuggerAddress: localhost:50634}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 8cbbf47848747b325357288d3e32a0d9
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:603)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:333)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:381)
at org.openqa.selenium.By$ById.findElement(By.java:194)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:325)

Expected behavior

I am expecting an error: NoSuchElementException

when implicitlyWait less than 60 second is ok, I get NoSuchElementException

Environment

OS: OSX 10.15.3 Browser: Chrome Browser version: 81.0.4044.113 Browser Driver version: ChromeDriver 80.0.3987.106

mmajcherczyk avatar Apr 18 '20 21:04 mmajcherczyk

This is likely an issue in Chromedriver not keeping the connection open for long enough. Please raise an issue with the ChromeDriver team

Please log chromedriver issues with the chromedriver project.

https://sites.google.com/a/chromium.org/chromedriver/help

Please be sure to include a completely reproducible test script for them, without a way to reproduce the issue you are seeing there is no good way for them to fix the problem. A reproducible test script includes a WebDriver script and a link to the page in question. If you can not provide a link, create one using jsfiddle.net

AutomatedTester avatar Apr 20 '20 20:04 AutomatedTester

@AutomatedTester it's not the chromedriver fault. I have the same error on firefox

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died. Build info: version: '4.0.0-alpha-5', revision: 'b3a0d621cc' System info: host: 'MacBook-Pro-2', ip: 'fe80:0:0:0:31:8ff8:ab39:5031%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.3', java.version: '1.8.0_191' Driver info: driver.version: RemoteWebDriver Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 75.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:buildID: 20200403170909, moz:geckodriverVersion: 0.26.0, moz:headless: false, moz:processID: 58277, moz:profile: /var/folders/hd/yrwc8tsx1tv..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 19.3.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify} Session ID: e1a117d3-2a21-9843-9e1c-f9088e04c9e1

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:603) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:333) at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:381) at org.openqa.selenium.By$ById.findElement(By.java:194) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:325)

in selenium 3.141.59 the problem does not occur

mmajcherczyk avatar Apr 21 '20 05:04 mmajcherczyk

This is likely hitting a HTTP client hitting a timeout after 1 minute.

AutomatedTester avatar Apr 21 '20 13:04 AutomatedTester

I am also getting this error when test tries to open URL that does not respond for 1 minute

mkozachenko avatar Jun 05 '20 13:06 mkozachenko

This error does not occur on my side. Envoriment: OS: Win10 Browser: Chrome Browser Version 85.0.4183.102 Browser Driver Version: ChromeDriver 85.0.4183.87 Selenium Version: 3.141.59

@mmajcherczyk you can try to upgrade your browser version

Buddy119 avatar Sep 20 '20 17:09 Buddy119

in chrome 85(selenium 4.0.0-alpha-6) when implicitlyWait equals 61 second i have error

java.lang.NoClassDefFoundError: org.openqa.selenium.WebDriverException

at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getConstructor(Class.java:1825)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:195)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:129)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:582)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:333)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:381)
at org.openqa.selenium.By$ById.findElement(By.java:194)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:325)

mmajcherczyk avatar Oct 05 '20 22:10 mmajcherczyk

It seems that chrome option "--no-sandbox" helps to get rid of this problem. I had this error for about 6 months until I found some years old post on StackOverflow with this very easy fix and it worked. I hadn't seen this exception for almost 2 months. @Buddy119 I got this error most of the times when the very first call of driver.get("web url") did not load anything for less then 60 seconds. Webpage has to just wait for response and not give response of any kind. You can try to emulate this with local proxy throttling - I did it with BrowserMobProxy method setLatency()

mkozachenko avatar Oct 13 '20 19:10 mkozachenko

The fix linked on the commit above should be available in the next beta, ~1 week from now.

diemol avatar Feb 09 '21 19:02 diemol