简体   繁体   中英

How to exit full screen (Chrome) in Selenium/Java other than using java.awt Robot class?

I have an application which enters full screen after login. Manually we can exit full screen by pressing 'ESCAPE' key. I have tried pressing ESCAPE key from Selenium using Actions class:

Actions action = new Actions(driver);
action.sendKeys(Keys.ESCAPE).build().perform();

But it's not working, the browser is still remains full screen.

I have also tried Robot class:

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ESCAPE);

This was working without headless mode but not in headless mode.

I want it to work in headless mode. Can anyone help please?

PS:- If anyone can suggest better way to key press (keyboard interaction) other than Robot class (Unfortunately Actions class is also not working).

driver.manage().window().maximize(); exits full screen mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM