How could I start a Selenium browser(like Firefox) minimized?

前端 未结 14 1366
野的像风
野的像风 2020-12-15 04:35

How could I start a Selenium browser (like Firefox) minimized? I want the command browser.start(mySettings) to start a browser minimized.

相关标签:
14条回答
  • 2020-12-15 05:30

    The best way to minimize your browser is to use shortcut using Robot class.

    Shortcut: Alt+Space+N (for Windows)

    Robot robot=new Robot();
    robot.keyPress(KeyEvent.VK_ALT);
    robot.keyPress(KeyEvent.VK_SPACE);
    robot.keyPress(KeyEvent.VK_N);
    robot.keyRelease(KeyEvent.VK_ALT);
    robot.keyRelease(KeyEvent.VK_SPACE);
    robot.keyRelease(KeyEvent.VK_N);
    

    By using above code you can minimize your browser.

    0 讨论(0)
  • 2020-12-15 05:31

    Without knowing your motive for minimizing the browser and assuming that you are using the WebDriver drivers (Selenium v2) and don't want a UI to pop up, one could use the lightweight browser HtmlUnitDriver.

    0 讨论(0)
提交回复
热议问题