6

我正在尝试从 FireFoxDriver 切换到 MarionetteDriver。我设法用 MarionetteDriver 运行 Firefox,方法是:

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);
}

但我有两件事我不知道该怎么做:

1.如何给驱动添加XPI扩展?以我使用的旧方式:FirefoxProfile.addExtension ...

2.如何配置所有的firefox属性,就像我以前做的那样,例如:

    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);

谢谢!

4

1 回答 1

3

您可以使用相同的 FirefoxProfile 类,只需按以下方式将其添加到 DesiredCapabilities 中:

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);
于 2016-06-11T03:41:15.340 回答