How to resolve “ org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/” with google driver?

后端 未结 2 1832
刺人心
刺人心 2020-12-03 19:52

I am facing above mentioned issue since 1 week. Earlier it was working smoothly. Even now sometimes it works fine but most of the time I am getting \"Failed to conne

相关标签:
2条回答
  • 2020-12-03 20:17

    Take a look at where you are instantiating the drive. You wrote: System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");

    I believe the issue is with the chrome drive path. Try: "D:/chromedriver.exe");

    There should be only one forward slash when defining the path.

    0 讨论(0)
  • 2020-12-03 20:28

    The error says it all :

    java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:4321 
    Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z' 
    System info: host: 'GURWUNknjk', ip: '10.202.126.154', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_131' 
    Driver info: driver.version: RemoteWebDriver
    

    The error clearly shows that the ChromeDriver was not recognized as in :

    Driver info: driver.version: RemoteWebDriver
    

    Your main issue is the version compatibility between the binaries you are using as follows :

    • You are using chromedriver=2.37
    • Your chrome version is unknown to us.
    • Your Selenium Client version is 3.11.0.
    • Your JDK version is 1.8.0_131 which is pretty ancient.

    So there is a clear mismatch between the JDK v8u131 , Selenium Client v3.11.0 , ChromeDriver version (v2.37).

    Solution

    • Upgrade JDK to recent levels JDK 8u162.
    • Keep ChromeDriver at current ChromeDriver v2.37 level.
    • Keep Chrome version at Chrome v65.x levels. (as per ChromeDriver v2.37 release notes)
    • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
    • Use CCleaner tool to wipe off all the OS chores 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.
    • Take a System Reboot.
    • Execute your @Test.
    0 讨论(0)
提交回复
热议问题