java.net.ConnectException: Connection refused: connect while launching Firefox through GeckoDriver

送分小仙女□ 提交于 2019-12-01 09:22:19

There aren't a lot of infos in your question, but I guess the following is an issue:

In

System.setProperty("webdriver.gecko.driver", "C:\XYZ\XXXX\Downloads\geckodriver-v0.20.1-arm7hf.tar.gz");

seems you are under a Windows OS (analyzing the path) but you are setting geckodriver-v0.20.1-arm7hf.tar.gz.

If you have a windows os, you should:

  1. Download from here the related version (geckodriver-v0.20.1-win64.zip or geckodriver-v0.20.1-win32.zip, it depends on your OS)
  2. Extract it and set, in the System.setProperty, the path to the extracted geckodriver.exe

Something like that:

System.setProperty("webdriver.gecko.driver", "C:\XYZ\XXXX\Downloads\geckodriver.exe");

If you are under another os, you should download the proper asset and do basically the same thing. If you hava a linux/mac os, you have to be sure that the extracted geckodriver is executable.

As per the Best Practices you need to follow the points below:

As you are on Windows OS download either geckodriver-v0.20.1-win32.zip or geckodriver-v0.20.1-win64.zip and unzip for your usage.

  • Always keep your Browsers updated with the latest releases (Firefox, Chrome, IE)
  • In the System.setProperty() line the Value field should end with the name of the WebDriver variant as:

    • Windows :

      System.setProperty("webdriver.gecko.driver", "C:\\XYZ\\XXXX\\Downloads\\geckodriver.exe");
      
    • Linux :

      System.setProperty("webdriver.gecko.driver", "/opt/XYZ/XXXX/geckodriver");
      
    • MacOSX :

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