Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fresh/tests/deps.ts>Page#setViewport

The next-gen web framework.
Extremely Popular
Go to Latest
method Page.prototype.setViewport
Re-export
import { Page } from "https://deno.land/x/fresh@1.2.0/tests/deps.ts";

page.setViewport will resize the page. A lot of websites don't expect phones to change size, so you should set the viewport before navigating to the page.

In the case of multiple pages in a single browser, each page can have its own viewport size.

Examples

Example 1

const page = await browser.newPage();
await page.setViewport({
  width: 640,
  height: 480,
  deviceScaleFactor: 1,
});
await page.goto('https://example.com');

Parameters

viewport: Viewport

Returns

Promise<void>