How to hide Firefox window (Selenium WebDriver)?

前端 未结 14 954
执念已碎
执念已碎 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:37

    In Java, you can use HtmlUnitDriver to launch a headless browser session which will not actually open the browser.

    Add the following dependency to your pom.xml (or download and reference the following):

    
        net.sourceforge.htmlunit
        htmlunit
        2.15
    
    

    ... and test it it as you would a WebDriver driver instance:

     driver = new HtmlUnitDriver();
     driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
     driver.get("http://www.google.com");
     // etc..
     driver.quit();
    

    Another similar question in SO: Avoid opening browser on remote server during selenium call

提交回复
热议问题