Reputation: 509
I'm working in Groovy\Java with Selenium WebDriver. Is there a way to check if the browser window is full screen (for example if someone pressed F11)? I have tried to search for other questions on StackOverflow but I have only found ways to set fullscreen, not to check if the window is already full screen.
Any ideas?
Upvotes: 0
Views: 2319
Reputation: 1
Check if the page source has the iframe
with the attribute allowFullScreen
.
Upvotes: 0
Reputation: 7466
I'm going to suggest using a JavascriptExecutor to check the status of the document.fullscreenElement.
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement fullScreen = (WebElement) js.executeScript("var element = document.fullscreenElement; return element");
It must be said that this does not appear to work on OSX, I always get a null back. It may of course be specifically targeted to things like video playback.
Upvotes: 2
Reputation: 33384
Have you tried this.
Dimension size = driver.manage().window().getSize();
int height = size.getHeight();
int width = size.getWidth();
System.out.println("height " + height + " width " + width);
Upvotes: 0