Back to FAQs

Is there a way to change the browser’s viewport, window, or screen size?

Loadster’s Browser Bots start with a 1280x720 viewport by default, which works fine for most sites. However, you might need to change it if your responsive site shows and hides key functionality, or displays altogether different elements, for certain screen sizes.

Responsive websites adapt to the browser’s size so that they work properly on a variety of devices. Specifically, the viewport is the section of a browser window where the actual web page is displayed. Most responsive sites respond to the viewport size rather than the window or screen size, so the viewport is what we adjust when we need the responsive site to look a certain way.

You can change the size of the Browser Bot’s viewport in a code block by calling browser.setViewportSize(width, height).

Setting the browser's viewport size before navigating to a site
Setting the browser's viewport size before navigating to a site

Once you’ve set the browser’s viewport size, it will remain the same for the remainder of that script iteration, unless you change it again.

Setting the viewport size is only relevant for Browser Bots, and won’t have any effect on Protocol Bots since they don’t have a real browser.