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

Time:12-07

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?

If anyone can suggest better way to key press (keyboard interaction) other than Robot class (unfortunately, Actions class is also not working).

CodePudding user response:

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

  • Related