简体   繁体   English

除了使用 java.awt 机器人 class 之外,如何在 Selenium/Java 中退出全屏(Chrome)?

[英]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.手动我们可以通过按“ESCAPE”键退出全屏。 I have tried pressing ESCAPE key from Selenium using Actions class:我尝试使用 Actions class 从 Selenium 按 ESCAPE 键:

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:我也试过机器人 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). PS:-如果有人可以建议除机器人 class 之外的更好的按键(键盘交互)方式(不幸的是,Actions class 也不起作用)。

driver.manage().window().maximize(); exits full screen mode.退出全屏模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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