Mahbub Rahman
Mahbub Rahman

Reputation: 1343

Geb: How to use Marionette instead of selenium Webdriver?

It is known issue that, Firefox version 47.0.1 is not compatible with Selenium latest version. Even Firefox is announcing to use Marionette instead. Can someone give some details instruction on how to use Marionette with Geb?

As a maven project, I tried all the version of Selenium with Geb but could not be successfull. I tried the following versions;

2.50.0

2.50.1

2.51.0

2.52.0

2.53.0

2.53.1

2.6.0

2.7.0

2.8.0

2.9.0

If this is not the right place to ask this, please guide me.

Upvotes: 0

Views: 1708

Answers (5)

Hashan Madushanka
Hashan Madushanka

Reputation: 1

public class Driver {
public FirefoxDriver getFirefoxDriver(){
    System.setProperty("webdriver.gecko.driver", "./geckodriver.exe");
    System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
    System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");
    FirefoxOptions options = new FirefoxOptions();
    options.setHeadless(true);
    return new FirefoxDriver(options);

}

}

Upvotes: 0

Jay
Jay

Reputation: 738

It should work with any of the late Selenium versions. (everything > 2.50 not sure for earlier versions)

Marionette is an external driver, it's not included in the Selenium packages (yet?)

You need to Download the gecko driver here https://github.com/mozilla/geckodriver/releases then point selenium to the location of the geckodriver.exe You can do that as Nelson said before in GebConfig with:

import org.openqa.selenium.firefox.MarionetteDriver

driver = {
    System.setProperty("webdriver.gecko.driver","path/geckodriver")
    new MarionetteDriver()
}

to make that work you will need some dependencies in your buildscript, I'm working with gradle, yours might look different, just look into what yours need to look like on maven central

compile('info.novatec.testit:webtester-support-marionette:2.0.4') { transitive = false }
compile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
compile "org.seleniumhq.selenium:selenium-support:$seleniumVersion"

(selenium support might not be necessary for you)

If you need more help, a more specific description of where you are failing would be helpful, you can also look here for a working project (with maven): http://seleniumsimplified.com/2016/04/how-to-use-the-firefox-marionette-driver/

Upvotes: 0

I have the next configuration in GebConfig.groovy:

firefox {
    System.setProperty("webdriver.gecko.driver","path/geckodriver")
    driver = {new MarionetteDriver()}
}

I am using selenium 3.0.1 and I using the -Dgeb.env=firefox system property in order to make sure it takes my Firefox configuration and it working fine for me

Regards

Upvotes: 2

Jeff Lowery
Jeff Lowery

Reputation: 2597

With version 48 of Firefox, it looks like the only solution is using marionnette, however I have not been able to get this to work in Geb yet.

This is what I have tried in GebConfig.groovy:

environments {

firefox {
    driver = {
        DesiredCapabilities dc = DesiredCapabilities.firefox();
        LoggingPreferences prefs = new LoggingPreferences();
        prefs.enable(LogType.BROWSER, Level.WARNING);
        dc.setCapability(CapabilityType.LOGGING_PREFS, prefs);
        dc.setCapability("marionette", true);

        String currentDir = System.getProperty("user.dir");
        String marionetteDriverLocation = currentDir + "/WebDriver/wires";
        System.setProperty("webdriver.gecko.driver", marionetteDriverLocation);

        FirefoxProfile p = new FirefoxProfile();
        p.setPreference("webdriver.gecko.driver", marionetteDriverLocation);
        p.setPreference("webdriver.log.file", "/tmp/firefox_console");
        p.setPreference("toolkit.telemetry.enabled", false);
        p.setPreference("geo.enabled", false);
        p.setPreference("plugins.update.notifyUser", false);

        p.setPreference("datareporting.healthreport.service.enabled", false);
        p.setPreference("datareporting.healthreport.uploadEnabled", false);
        p.setPreference("datareporting.policy.dataSubmissionEnabled",false);
        p.setPreference("datareporting.healthreport.service.firstRun", false);
        p.setPreference("datareporting.healthreport.logging.consoleEnabled", false);
        p.setPreference("reader.parse-on-load.enabled", false);

        dc.setCapability(FirefoxDriver.PROFILE, p);

        def driver = new FirefoxDriver(dc)
        driver.manage().timeouts().pageLoadTimeout(45, TimeUnit.SECONDS)
        return driver
    }

Upvotes: 0

kumar
kumar

Reputation: 66

Download the latest version of selenium standard version 2.53.1 from selenium.hq.org.downloads and try to use the newest version of the Firefox.

Upvotes: 1

Related Questions