How to minimize the browser window in Selenium WebDriver 3

前端 未结 7 1123
南方客
南方客 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:30

    Use the following code to the minimize browser window. It worked for me and I am using Selenium 3.5:

    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);
    

提交回复
热议问题