How to use firefox webdriver (geckodriver) in selenium?

0 votes

I am unable to use geckodriver with selenium in Java. I am using firefox v42 and geckodriver v23. 

The code I am using is as follows:-

System.setProperty("webdriver.gecko.driver","C:\\Users\\Downloads\\Firefox1\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com");
driver.close();

The problem that I am facing is that geckodriver is opening but after opening I am getting an error like this:-

1546939047470 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\USER\\AppData\\Local\\Temp\\rust_mozprofile.vGrGyrenGEXG"

1546939048169 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: resource://pdf.js/

1546939048169 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: about:reader*

1546939051379 Marionette INFO Listening on port 60160
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}], required capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}]
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'DESKTOP-TGAB9Q5', ip: '192.168.173.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
    at Firefox.main(Firefox.java:16)
Jan 7 in Selenium by Anjali
• 2,900 points
920 views

1 answer to this question.

0 votes

Firefox v47+ with selenium 2.53, you need marionette driver and you export its absolute path to variable webdrive.gecko,driver as system property.

Firefox v47+ will support geckodriver only.

Please upgrade to selenium java binding 3.4+

If you use old version of Morzilla Firefox and newer version of Selenium you will be facing error like :

Exception in thread "main" java.lang.IlleagalStateException

If you use new version of Morzilla Firefox and older version of Selenium you will be facing error like:

org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session.

Hence as a suggestion use:

Firefox V64 as of Jan 2019

Selenium 3.4+

answered Jan 8 by Nabarupa
I am able to open the Firefox browser but I am not able to open any url. I followed your steps, still facing the same issue.
Hey @Shashank, can you tell me as which version of Eclipse, selenium and geckodriver are you using?
I am using Firefox v40 and selenium 3.1
Hey @Shashank, use firefox v 64 and selenium 3.3.1 this works best.
Okay, thank you. I will try this

Related Questions In Selenium

0 votes
1 answer

How to use Actions class in Selenium Webdriver?

In seleniun webdriver it is not mandatory ...READ MORE

answered Apr 4, 2018 in Selenium by Damon Salvatore
• 5,510 points
2,394 views
0 votes
1 answer

How to use webdriver in selenium?

In Java, in order to call the ...READ MORE

answered Dec 20, 2018 in Selenium by Shuvodip
71 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
422 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
777 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
415 views
+9 votes
14 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,250 points
53,940 views
0 votes
5 answers