使用Selenium时如何绕过firefox更新页面?

Rid*_*del 5 java firefox junit selenium

我在Firefox浏览器上运行了一些selenium测试.不幸的是,虽然我注意创建一个新的配置文件,但是/firstrun/当我的测试开始时,我总是会显示Firefox 的页面,这很烦人,因为该页面通过Web获取内容.

我试过以下方式禁用它

    FirefoxProfile profile = new FirefoxProfile(profileDir);
    if(!exists) {
        profile.setPreference("signed.applets.codebase_principal_support", true);
        profile.setPreference("capability.principal.codebase.p0.granted", true);
        profile.setPreference("startup.homepage_override_url", "about:blank");
        profile.setPreference("browser.startup.homepage_override.mstone", "'ignore'");
Run Code Online (Sandbox Code Playgroud)

但它仍然显示出来.

我该怎么做才能确保Firefox没有显示页面?

Hub*_*ert 1

基里尔提出了正确的问题 - “为什么使用单引号?”。没有它对我有用。

 profile.setPreference("browser.startup.homepage_override.mstone", "ignore");
Run Code Online (Sandbox Code Playgroud)

另一种方法是在创建 Firefox 实例后加载空白页面 (driver.get("about:blank");)