12

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.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
saikiran
  • 2,247
  • 5
  • 27
  • 42
  • All we have is the stack trace here. Please provide more info to increase your chances of getting an answer. What code (small chunk of it) reproduces this issue? What changed in the system between when it worked and when it failed? Have you tried running this on a fresh system? Does it fail there? – Vish Apr 11 '14 at 23:48
  • Also, given that you received a permission denied error, did u check if your firewall is blocking selenium? – Vish Apr 11 '14 at 23:50
  • i am working on the same system and i dnt think my firewall is blocking selenium. you want me to show my code what i have written @Vish – saikiran Apr 12 '14 at 00:14
  • 1
    Please double check that your firewall is indeed not the issue. Random failures typically point at this kind of stuff. And yeah, code is needed - but dont go overboard, only paste the code thats needed. – Vish Apr 12 '14 at 00:17
  • 1
    That exception on its own could be anything: from driver compatibility issues to network problems. So stack trace is not helpful in this case. If you are using RemoteWebDriver to run tests remotely from machine A to machine B, then try to run them locally on machine B. And if you are not running tests remotely, try to see what happens if you use WebDriver and not remote driver (not a hard switch). Will help you to eliminate networking issues and driver issues – user1433852 Apr 12 '14 at 02:51
  • i am not using remote web driver , i am calling as WebDriver driver = new FirefoxDriver(); – saikiran May 02 '14 at 13:37
  • Is the following question a duplicate of this question? - http://stackoverflow.com/questions/8727655/internetexplorerdriver-may-have-died-selenium-issue/25497982 – Nick Grealy Aug 26 '14 at 04:22

4 Answers4

10

Problem

I had the same problem running InternetExplorerDriver locally in Windows 7 - (IEDriverServer_Win32_2.42.0.zip)

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

When I checked the running processes under TaskManager, there were multiple IEDriverServer.exe processes running, that hadn't been cleaned up properly.

Solution

Running the following command, killed all running IEDriverServer.exe processes, and resolved this issue (for me).

taskkill /F /IM IEDriverServer.exe
Nick Grealy
  • 24,216
  • 9
  • 104
  • 119
  • 2
    Do you happen to know what the Firefox version is? – Fallenreaper Sep 29 '16 at 14:43
  • @Fallenreaper ... er... for my scenario, I had the same exception, but using InternetExplorer instead of Firefox... so no Firefox, just InternetExplorer. – Nick Grealy Sep 30 '16 at 03:59
  • seems one of the known selenium issue https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4319 – TechDog Aug 03 '17 at 14:31
  • im getting the same error while running firefox / chrome on ubuntu. How to resolve this issue on ubuntu? – Nisrine Bou Ghannam Dec 10 '20 at 06:47
  • @NisrineBouGhannam - if you want to kill processes in Ubuntu, there's plenty of info on the internet - e.g. https://askubuntu.com/questions/104903/how-do-i-kill-processes-in-ubuntu – Nick Grealy Dec 11 '20 at 03:34
0

I followed these steps and the problem got resolved:

  1. get the firefox profile name

    • try this command on run window firefox.exe -P or firefox.exe -P or firefox.exe -profilemanager

One of the above command will open pop up stating the name of Default profile which is nomaly "default"

  1. Use below mentioned code for gettingthe firefox driver

    ProfilesIni allProfiles = new ProfilesIni();
    FirefoxProfile myProfile = allProfiles.getProfile("default");
    myProfile.setAcceptUntrustedCertificates(true);
    myProfile.setAssumeUntrustedCertificateIssuer(true);
    driver = new FirefoxDriver(myProfile);
    
Tom
  • 1,387
  • 3
  • 19
  • 30
0

For me using a port starting with a 1, rather than a port close to the default port value 5555, caused me to have this error. Changing the node port from 1234 back to 5558 has solved the issue. Not sure how ports work but it seems 1234 was unstable

-3

Please try to replace exe path with below command

File file = new File("IE DriverServer.exe path");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
Jamie Rees
  • 7,973
  • 2
  • 45
  • 83