power_settings_new

how to get width of a browser window using javascript?

by
asked
0 votes
95 views
I am automating test cases using Selenium WebDriver. I am currently executing tests using iPhone device. Screen arranges elements based on screensize. I want to know java script command to get widnth of window/htlml document

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by
selected by
0 votes
 
Best answer

You can try below code:

 

JavascriptExecutor js = (JavascriptExecutor) driver;
Long width = (Long)js.executeScript("return window.innerWidth;");
 
add
...