How to minimize the browser window in Selenium WebDriver 3

前端 未结 7 1020
南方客
南方客 2021-01-05 18:14

After maximizing the window by driver.manage().window().maximize();, how do I minimize the browser window in Selenium WebDriver with Java?

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 18:23

    There seems to be a minimize function now:

    From the documentation on:

    webdriver.manage().window()

    this.minimize() → Promise
    Minimizes the current window. The exact behavior of this command is specific to individual window managers, but typicallly involves hiding the window in the system tray.
    
    Parameters
    None.
    
    Returns
    Promise
    A promise that will be resolved when the command has completed.
    

    So the code should be:

    webdriver.manage().window().minimize()
    

    At least in JavaScript.

提交回复
热议问题