Skip to content
masterclass Buddy

Playwright · Method

page.setViewportSize

Sets the viewport size for one Playwright page. Width and height are given in pixels.

Last updated

Since
v1.10

Syntax

page.setViewportSize(int width, int height);

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Browser.newContext
  • Browser.NewContextOptions.setViewportSize
  • viewportSize
  • setDeviceScaleFactor
  • setScreenSize

Source: Emulation | Playwright Java. Checked 2026-11-03.