从Firefox WebDriver迁移到Marionette

use*_*203 6 selenium webdriver firefox-marionette

我正在尝试从FireFoxDriver切换到MarionetteDriver.我设法通过运行以下命令运行firefox和MarionetteDriver:

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);
}
Run Code Online (Sandbox Code Playgroud)

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

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);
Run Code Online (Sandbox Code Playgroud)

谢谢!

I_A*_*NDA 3

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

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);
Run Code Online (Sandbox Code Playgroud)

  • 我想知道还有没有更多的事情。我尝试添加功能,但设置下载目录和自动下载仍然对我不起作用。 (3认同)