-1

I get exception:

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

Every time i use on Safari:

Actions action = new Actions(WebDriverRunner.getWebDriver());
    action.click(packageCodeButton()).build().perform();
    

I use devices on BrowserStack (iPhones), and MacOS. When i select 12 as browser it works on MacOS.

Problem appears only on Safari, not any other browser. It also doesn't mather which element i try to click or when i do this (on which test phase). Other selenium commands works correct( i use selenide framework).

Can someone help me with this error?

Similar question was asked: stack

But there is only sporadic problem with all browsers and random commands. In my case it looks like some Safari driver bug.

EDIT:

Stacktrace:

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: 'L069G', ip: '10.212.130.34', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11' Driver info: driver.version: RemoteWebDriver Capabilities {64bit: false, acceptSslCert: false, acceptSslCerts: false, automationName: XCUITest, bootstrapPath: /usr/local/.browserstack/co..., browser: iphone, browserName: safari, browser_name: Safari, browserstack-tunnel: true, browserstack.isTargetBased: false, databaseEnabled: false, detected_language: selenium/3.141.59 (java win..., device: iphone, deviceName: iPhone 7, deviceOrientation: PORTRAIT, javascriptEnabled: true, locationContextEnabled: false, loggingPrefs: org.openqa.selenium.logging..., mobile: {browser: mobile, version: iPhone 7-12.1}, networkConnectionEnabled: false, newCommandTimeout: 0, new_bucketing: true, noReset: true, orientation: PORTRAIT, orig_os: ios, osVersion: 12, os_version: 12, platform: MAC, platformName: MAC, platformVersion: 12.1, realMobile: true, real_mobile: true, safari.options: {}, safariIgnoreFraudWarning: true, safariInitialUrl: http://mobile-internet-chec..., sessionName: , takesScreenshot: true, udid: ..., useXctestrunFile: true, version: , wda_port: 8405, webStorageEnabled: false, webkitResponseTimeout: 20000} Session ID:

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteMouse.click(RemoteMouse.java:59)
at org.openqa.selenium.interactions.ClickAction.perform(ClickAction.java:39)
at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:34)
at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:642)
at TestHelpers.Helpers.GoogleMap.selectClosestOnMapMobile(GoogleMap.java:99)(file:Tests/src/test/resources/1_SPY-2619.feature:12)

Caused by: java.lang.IllegalArgumentException: expected one element but was: <unknown method, unsupported operation>

BrowserStack visual log shows info:

Method has not yet been implemented

Kamil1014
  • 27
  • 8
  • Instead of using the actions to click, can you use a normal .Click() or use the javascript approach? - I know it's not ideal but it might be a workaround to get you past this problem.... Have you also let browserstack know about your problem? They're might be aware and have a workaround as it's what they do – RichEdwards Aug 18 '20 at 05:54
  • @RichEdwards I can't use normal click() and js approach, becouse i try to click on GoogleMap and both of them don't work (with normal error 'another element would recive action' with js no visible result of click) . I will write to BrowserStack if i don't get help here. – Kamil1014 Aug 18 '20 at 06:54

1 Answers1

0

This error message...

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

...implies that the RemoteWebDriver instance was closed abruptly.

The complete error stack trace would have been of some help to debug the issue in a better way. However, as per the article WebDriver fix for UnreachableBrowserException the possible cause and the solution can be either of the following:

  • If the cause is java.net.SocketException: Software caused connection abort: recv failed: This error occurs when the connection is closed prematurely. It may have caused by ssl certificate handling in java which is extremely random as all http traffic is handled by the execute method. So by overriding it and adding simple retry functionality you can provide a workaround.

  • If the cause is java.net.SocketTimeoutException: Read timed out: If you're working on a system, the chances are there 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 within:

    • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters: 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 !!!).


Additional Considerations

Ensure that:

  • JDK is upgraded to current levels JDK 8u251.

Note: you are using java.version: '11'. For the record Selenium is still not fully compatible with . For more details follow the discussion Unable to import org.openqa.selenium.WebDriver using Selenium and Java 11

  • Upgrade Selenium to current levels Version 3.141.59.

  • Upgrade ChromeDriver to current ChromeDriver v84.0 level.

  • Upgrade Chrome to current Chrome v84.0 (as per ChromeDriver v84.0 release notes).

  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.

  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.

  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.

  • As you have mentioned running a bunch of test cases every hour possibly there are multiple dangling instances of ChromeDriver and Chrome which can be viewed through the process list (Linux OS) or TaskManager (Windows OS). You need to always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

  • If the dangling instances of WebDriver and Web Browser still persists consider killing them with brute force. You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?

  • Incase you program is attempting to set up TCP connections from ports that are greater than 5000 you can refer this article


References

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352