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

前端 未结 4 1166
感情败类
感情败类 2020-12-04 03:46

Recently I upgraded to Selenium 3.7.

Code:

import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.firefox.FirefoxDriver;


public static         


        
相关标签:
4条回答
  • 2020-12-04 04:10

    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
    
    0 讨论(0)
  • 2020-12-04 04:19

    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

    0 讨论(0)
  • 2020-12-04 04:20

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

    System.setProperty("webdriver.gecko.driver", 
        "/usr/local/bin/geckodriver.exe");
    
    0 讨论(0)
  • 2020-12-04 04:25

    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.
    0 讨论(0)
提交回复
热议问题