Skip to main content

getPuppeteer

Overview

Use the getPuppeteer command to get an instance of the browser's Puppeteer in order to execute specialized commands with it.

Please note that all Puppeteer commands are asynchronous by default, so to switch between synchronous and asynchronous execution, be sure to wrap Puppeteer calls in browser.call, as shown in the example below.

warning

The getPuppeteer command only works when using Chrome DevTools Protocol (CDP).

Read more in the section "How to use Chrome DevTools Protocol in testplane".

Usage

await browser.getPuppeteer();

Usage Examples

it("should allow me to use Puppeteer", async ({ browser }) => {
await browser.url("https://webdriver.io");

const puppeteerBrowser = await browser.getPuppeteer();

// switch to Puppeteer
const metrics = await browser.call(async () => {
const pages = await puppeteerBrowser.pages();

await pages[0].setGeolocation({ latitude: 59.95, longitude: 30.31667 });

return pages[0].metrics();
});

console.log(metrics.LayoutCount); // outputs: 42
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.