How to hide Firefox window (Selenium WebDriver)?

前端 未结 14 948
执念已碎
执念已碎 2020-11-27 11:08

When I execute multiple test simultaneously, i don\'t want to keep Firefox browser window visible.. I can minimize it using selenium.minimizeWindow() but I don\

14条回答
  •  鱼传尺愫
    2020-11-27 11:40

    The default browser of PhantomJS is IE, though many browser features do not work there. If you want to open a headless(hidden) Firefox window, you can use the new feature of Firefox 56+.

    With this feature you can get a headless driver like this:

    System.setProperty("webdriver.gecko.driver", firefoxDriverExePath);
    FirefoxOptions options = new FirefoxOptions();
    options.addArguments("--headless");
    FirefoxDriver driver = new FirefoxDriver(options);
    

    New versions of Chrome also have the headless option.

提交回复
热议问题