0

When I execute a Selenium Script using Firefox, the Firefox opens up but it doesn't redirect to the URL. Below is the error which is displayed on the Eclipse Console:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
console.error: JsonSchemaValidator.jsm

my script is below :

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

public class Authentication {

    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver","C:/usine-dev/workdir/workspace/test-bleu-horizon/src/test/resources/drivers/geckodriver.exe" );
        WebDriver driver = new FirefoxDriver();
        driver.get("https://github.com/");
    }
}

I am using selenium-java-4.10.0.jar, and geckodriver (v0.32.0 ) firefox 102.9.0esr (32 bits), windows 10

And I have tried all the version but I usually have the same error

Shawn
  • 4,064
  • 2
  • 11
  • 23

2 Answers2

0

Since you are using selenium v4.10.0, you don't really have to set the path of driver.exe any more. Selenium's new module known as SeleniumManager will do the job of handling browsers and browser drivers for you.

Remove the below line and try, see if that resolves the issue:

System.setProperty("webdriver.gecko.driver","C:/usine-dev/workdir/workspace/test-bleu-horizon/src/test/resources/drivers/geckodriver.exe" );

Just keep it like:

public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("https://github.com/");
    }

UPDATE: If despite doing above it doesn't work, update firefox to the latest one and retry if that solves the issue.

Shawn
  • 4,064
  • 2
  • 11
  • 23
0

The plain vanila Firefox and the Firefox Extended Support Release or Rapid Release aren't the same.


Solution

To open the Selenium driven GeckoDriver initiated Firefox Extended Support Release or Rapid Release browsing context you need to pass the absolute location of the firefox x.y.z ESR binary through setBinary() method of the FirefoxOptions object as follows:

FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\path\\to\\firefoxESR.exe");
WebDriver driver = new FirefoxDriver(options);
driver.get("https://github.com/");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352