Skip to content

Commit

Permalink
docs(api.md): add notes on race condition in page.setViewport (#4319)
Browse files Browse the repository at this point in the history
Fixes #2755.
  • Loading branch information
aslushnikov committed Jun 11, 2019
1 parent 8df0b3e commit 65b7e8e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/api.md
Expand Up @@ -1249,7 +1249,8 @@ Emulates given device metrics and user agent. This method is a shortcut for call
- [page.setViewport(viewport)](#pagesetviewportviewport)

To aid emulation, puppeteer provides a list of device descriptors which can be obtained via the [`puppeteer.devices`](#puppeteerdevices).
Below is an example of emulating an iPhone 6 in puppeteer:

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

```js
const puppeteer = require('puppeteer');
Expand Down Expand Up @@ -1815,6 +1816,18 @@ puppeteer.launch().then(async browser => {
In the case of multiple pages in a single browser, each page can have its own viewport size.

`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.

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

#### page.tap(selector)
- `selector` <[string]> A [selector] to search for element to tap. If there are multiple elements satisfying the selector, the first will be tapped.
- returns: <[Promise]>
Expand Down

0 comments on commit 65b7e8e

Please sign in to comment.