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, 2019 in Selenium by Anjali
• 2,950 points
6,989 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, 2019 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,980 points
3,889 views
0 votes
2 answers

How to use webdriver in selenium?

Hi, Selenium provides drivers specific to each browser ...READ MORE

answered Feb 21, 2020 in Selenium by surbhi
• 260 points
629 views
0 votes
1 answer
0 votes
1 answer

How to open Firefox window in Incognito mode using Selenium Webdriver?

Hi Pritha, you can use this code ...READ MORE

answered May 14, 2019 in Selenium by Anvi
• 14,150 points
6,562 views
0 votes
2 answers

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,500 points
12,617 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,572 views
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,910 points
6,629 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,519 views
+10 votes
17 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,360 points
193,874 views
0 votes
8 answers

How to open a link in new tab of chrome browser using Selenium WebDriver?

This below code works for me in ...READ MORE

answered Dec 14, 2020 in Selenium by Gitika
• 65,910 points
101,454 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP