mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.03k stars 1.51k forks source link

Session cannot be started while doing "System.setProperty("webdriver.gecko.driver", "geckodriver.exe");" with geckodriver V: 0.34.0 #2160

Closed kashyapparikh012 closed 4 months ago

kashyapparikh012 commented 4 months ago

System

Testcase

Session cannot be started while doing "System.setProperty("webdriver.gecko.driver", "geckodriver.exe");"

I am trying to invoke Firefox browser with the help of selenium and geckodriver V: 0.34.0 and noticed that while setting up system property, if we provide key = "webdriver.gecko.driver", then new session cannot be started. If we change key to either "webdriver.firefox.driver" or "webdriver.driver.gecko", then it opens firefox browser without any issue.

"System.setProperty("webdriver.gecko.driver", "geckodriver.exe");" works fine with geckodriver V: 0.33.0.

Sample Code

package selenium1;

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

public class FirefoxDriverIssue {

public static void main(String[] args) {
    System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
    WebDriver driver = new FirefoxDriver();
    driver.get("https://google.com");

}

}

Stacktrace

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line Build info: version: '4.17.0', revision: 'e52b1be057*' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.3.1' 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.ProtocolHandshake.createSession(ProtocolHandshake.java:139) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:95) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162) at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:233) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:162) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:155) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:150) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:133) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:128) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:113) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:103) at selenium1.FirefoxDriverIssue.main(FirefoxDriverIssue.java:10)

Trace-level log

whimboo commented 4 months ago

Thank you for the report. By reading your comment it sounds that this is a problem with the used Selenium binding and not with geckodriver. As such please consult their documentation and if it's not solvable consider filing an issue in their issue tracker. Thanks.