Selenium error: SessionNotCreatedException | Java, Firefox, everything is updated and should be compatible

25 Views Asked by At

I am confused why this issue is happening because I have the latest versions of everything I am working with: I am working in Java (version 22) My Geckodriver is version 34 All the jars I have for selenium are version 4.18.1 My firefox browser is the latest ESR version (115.9.1)

Also for reference my current IDE is IntelliJ.

I checked and these should all be compatable, but I am getting the following error when I try and inialize my FirefoxDriver:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'MATTHEWLAPTOP', ip: '141.219.236.17'
Build info: version: '4.18.1', revision: 'b1d3319b48'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '22'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {}}]}]
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:537)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:233)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:162)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:155)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:150)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:133)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:128)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:113)
    at Main.main(Main.java:88)
Caused by: java.io.UncheckedIOException: java.io.IOException: Cannot run program "geckodriver.exe": CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher
    at org.openqa.selenium.os.ExternalProcess$Builder.start(ExternalProcess.java:193)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:207)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:117)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519)
    ... 8 more
Caused by: java.io.IOException: Cannot run program "geckodriver.exe": CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1089)
    at org.openqa.selenium.os.ExternalProcess$Builder.start(ExternalProcess.java:191)
    ... 11 more
Caused by: java.io.IOException: CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher
    at java.base/java.lang.ProcessImpl.create(Native Method)
    at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:500)
    at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1126)
    ... 13 more

Process finished with exit code 1

For reference it doesn't like breifly open firefox and then crash and close it. Looking at where the error happens, this is the RemoteWebDriver.java execute method:


protected Response execute(CommandPayload payload) {
    Command command = new Command(sessionId, payload);
    Response response;

    long start = System.currentTimeMillis();
    String currentName = Thread.currentThread().getName();
    Thread.currentThread()
        .setName(
            String.format("Forwarding %s on session %s to remote", command.getName(), sessionId));
    try {
      log(sessionId, command.getName(), command, When.BEFORE);
      response = executor.execute(command);
      log(sessionId, command.getName(), response, When.AFTER);

      if (response == null) {
        return null;
      }

      // Unwrap the response value by converting any JSON objects of the form
      // {"ELEMENT": id} to RemoteWebElements.
      Object value = getElementConverter().apply(response.getValue());
      response.setValue(value);
    } catch (Throwable e) {
      log(sessionId, command.getName(), e.getMessage(), When.EXCEPTION);
      WebDriverException toThrow;
      if (command.getName().equals(DriverCommand.NEW_SESSION)) {
        if (e instanceof SessionNotCreatedException) {
          toThrow = (WebDriverException) e;
        } else {
          toThrow =  //(And this is line 537 where the error happened)
              new SessionNotCreatedException(
                  "Possible causes are invalid address of the remote server or browser start-up"
                      + " failure.",
                  e);
        }
      } else if (e instanceof WebDriverException) {
        toThrow = (WebDriverException) e;
      } else {
        toThrow =
            new UnreachableBrowserException(
                "Error communicating with the remote browser. It may have died.", e);
      }
      populateWebDriverException(toThrow);
      // Showing full command information when user is debugging
      // Avoid leaking user/pwd values for authenticated Grids.
      if (toThrow instanceof UnreachableBrowserException && !Debug.isDebugging()) {
        toThrow.addInfo(
            "Command",
            "["
                + command.getSessionId()
                + ", "
                + command.getName()
                + " "
                + command.getParameters().keySet()
                + "]");
      } else {
        toThrow.addInfo("Command", command.toString());
      }
      throw toThrow;
    } finally {
      Thread.currentThread().setName(currentName);
    }

    try {
      errorHandler.throwIfResponseFailed(response, System.currentTimeMillis() - start);
    } catch (WebDriverException ex) {
      populateWebDriverException(ex);
      ex.addInfo("Command", command.toString());
      throw ex;
    }
    return response;
  }

My code is:

                import org.openqa.selenium.firefox.FirefoxDriver;
                import org.openqa.selenium.firefox.FirefoxOptions;
                public class Main {
                    public static void main(String[] args) {
                            String pathOfFireFoxDriver = "geckodriver.exe";
                        FirefoxOptions options = new FirefoxOptions();
                        System.setProperty("webdriver.gecko.driver", pathOfFireFoxDriver);
                        FirefoxDriver fireFoxDriver = new FirefoxDriver(options);
                    }
                }
0

There are 0 best solutions below