Migrating from Firefox WebDriver to Marionette

4.2k Views Asked by At

I am trying to switch from FireFoxDriver to MarionetteDriver. I managed to run firefox with MarionetteDriver by running:

public void runMarionnete(){
    DesiredCapabilities dc = DesiredCapabilities.firefox();
    OSUtils.setProperty("webdriver.firefox.bin", "C:\\Firefox\\firefox.exe");
    OSUtils.setProperty("webdriver.gecko.driver","C:\\Drivers\\wires-0.6.2-win.exe"));
    _driver = new MarionetteDriver(dc);
}

But I have 2 things I am not sure how to do:

1.How to add XPI extensions to the driver ? in the old way I used: FirefoxProfile.addExtension ...

2.How to configure all the firefox properties , like I used to do , for example:

    profile.setPreference("browser.startup.homepage;about:home","about:blank");
    profile.setPreference("startup.homepage_welcome_url","about:blank");
    profile.setPreference("browser.usedOnWindows10.introURL","about:blank");
    profile.setPreference("devtools.devedition.promo.url","");
    profile.setPreference("xpinstall.signatures.required",false);

Thank you!

1

There are 1 best solutions below

3
On

You can use the same FirefoxProfile class, just add it to the DesiredCapabilities in the following way:

FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.startup.homepage;about:home","about:blank");
firefoxProfile.setPreference("startup.homepage_welcome_url","about:blank");
firefoxProfile.setPreference("browser.usedOnWindows10.introURL","about:blank");
firefoxProfile.setPreference("devtools.devedition.promo.url","");
firefoxProfile.setPreference("xpinstall.signatures.required",false);

DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);