How to set viewport size in WebDriver

215 views
Skip to first unread message

Gareth

unread,
Jan 13, 2017, 10:46:45 PM1/13/17
to Selenium Users
It is easy to set the window size with driver.manage().window().setSize() but I'd like to set a WebDriver to use a specific viewport size. I am working in Java.

Kendall Schmidt

unread,
Jan 17, 2017, 12:55:36 PM1/17/17
to Selenium Users
What would be the use case for this? Is your intent to restrict the area of a displayed page that the WebDriver would interact with - i.e. locate/click web elements? If this is the case, I would doubt that would be an applicable/in scope functionality of the WebDriver as the WebDriver is basically intended to interact with the DOM not a graphic viewport.

If my assumption is correct, you want to limit the area of the display the WebDriver interacts with (I guess for performance reasons?), and the displayed page has frames, I guess you could equate restricting the WebDriver to a specific frame (driver.swirchTo().frame()) as restricting the WebDriver to a "viewport".
Reply all
Reply to author
Forward
0 new messages