Selenium 3.7 : geckodriver : WebDriverException: org.apache.http.conn.HttpHostConnectException Connection Refused

懵懂的女人 提交于 2019-11-27 16:26:01

The error WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8970 can occur due to different reasons. More over there is a discrepency in your Included Library list as selenium-server-standalone-3.7.1.jar is never a part of downloaded selenium-java-3.7.1.zip.

Try out the steps mentioned below:

  • From the Included Library list remove all the jars.
  • Download and Add only selenium-server-standalone-3.7.1.jar from this link or from this link
  • Ensure that /etc/hosts on your system contains the following entry :

    1 127.0.0.1               localhost.localdomain localhost
    
  • Run CCleaner Tool to wipe away all the OS chores from your system.

  • You can opt for a System Reboot.
  • Execute your Test.

I tried with the same versions without any problem.

If the path to the geckodriver:

System.setProperty("webdriver.gecko.driver", 
    "/usr/local/bin/geckodriver"); 

is correct, make sure that the geckodriver is executable for the user that execute the code:

chmod +x geckodriver

After doing some research, I manage to resolve this problem.

The error is due to the 127.0.0.1 map to localhost.com in etc/hosts. Edited: 127.0.0.1 localhost

AbhishekK

I think you are missing the .exe extension. Your path should be like this

System.setProperty("webdriver.gecko.driver", 
    "/usr/local/bin/geckodriver.exe");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!