3

I've been attempting to use Selenium to drive Firefox for the fist time. I used virtually identical code to drive Chrome without issue. However, when I attempt to use the Firefox driver, the browser opens, stalls, and then, after about 60 seconds, I get an error report that reads as follows:

Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: 4474-a285-3208198ce6fd}","syncGUID":"dcskEFBTLyBH","location":"app-global","version":"48.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1471881400240,"updateDate":1471881400240,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"48.0.1","maxVersion":"48.0.1"}],"targetPlatforms":[],"seen":true} 1472056603181 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd} 

I've checked other guides and all they recommend is that I update my .jar files. I am using selenium-java-3.0.0-beta2 and Firefox 48.0.1 to test so my files are up to date. I would like to get this to run properly.

UPDATE: code still does not work and I've set the System property to set the geckodriver properly. However, I still cannot get the driver to function properly. It won't even launch the browser any more.

import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.DesiredCapabilities; public class SimpleFireFoxDriver { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver","C:\\Selenium\\geckodriver.exe"); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(); driver.get("http://www.youtube.com"); System.out.println("Made it to the promised land"); driver.quit(); } } 

Edit: Also the path to FireFox itself is located here: "C:\Program Files\Mozilla Firefox\firefox.exe"

2
  • From the firefox console, it appears it is trying to install add-on on firefox for webdriver (the traditional approach before geco driver). You might want to set "webdriver.firefox.marionette" as true to explicitly mention the gecko driver to be used. Just a suggestion as it should be the default case. Commented Aug 24, 2016 at 17:08
  • try to run code after removing this line System.setProperty("webdriver.firefox.marionette","C:\\Selenium\\geckodriver.exe"); Commented Aug 24, 2016 at 17:39

5 Answers 5

5

Changing the system property worked for me. Change it to following:

System.setProperty("webdriver.firefox.marionette","src\\test\\java\\lib\\geckodriver.exe"); driver= new FirefoxDriver(); 

Hope that helps.

Sign up to request clarification or add additional context in comments.

2 Comments

Thats awesome, how did you get this answer, thanks a lot for saving hell lot of time.
Where does this config comes from ? By the way, when I use this key, my browser launches but with a blank page
3

This is happening because you have set the wrong system property. You need to set system property as follows:

System.setProperty("webdriver.gecko.driver","C:\\Selenium\\geckodriver.exe"); 

Selenium firefox driver expects this System property to be set before initiating marionette driver and launching firefox. And if you don't set any System property and try to instantiate Firefox driver then you will get following error : "The path to the driver executable must be set by the webdriver.gecko.driver system property."

Hope this helps.

5 Comments

I tried this system property and got the following error: C:\Selenium\geckodriver.exe [OPTIONS] C:\Selenium\geckodriver.exe: Unknown option --port=25646 Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
I have tried this with geckodriver v0.10.0, firefox v48.0.1 and selenium-server-standalone-3.0.0-beta2.jar. Can you try with this configuration?
I tried gecko v0.10.0 (was previously using v0.9.0) and it works now. Thank you. I wasn't aware that v0.10.0 was out.
Glad it helped you. If this solved your issue, you can accept this answer :)
I confirmed that on MAC OS geckodriver v0.9 port error are gone with v0.15. Download link: github.com/mozilla/geckodriver/releases
2

Changing "webdriver.gecko.driver" with "webdriver.firefox.marionette" saved my life! example:

Correct

System.setProperty("webdriver.firefox.marionette","C://selenium/gecko/geckodriver.exe"); 

Not correct

System.setProperty("webdriver.gecko.driver","C://selenium/gecko/geckodriver.exe"); 

Comments

1

Download the latest Gecko driver V0.17.0 and this resolved my error without changing the setProperty or downgrading of Firefox browser.

Not so sure, whether this may help you.

Comments

1

Changing "webdriver.gecko.driver" with "webdriver.firefox.marionette" saved my Life Also Downgrading Firefox from 50 to 36

Or try this code:

System.setProperty("webdriver.firefox.marionette", "D://Driver//geckodriver.exe"); WebDriver driver = new FirefoxDriver(); 

1 Comment

While you downgrade to a version previous to 47 you should be ok. You can try with 45 (ESR).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.