Skip to main content

Puppeteer

BrowserCloud supports puppeteer. The latter can be successfully used provided that the appropriate app or service are updated. To use the BrowserCloud service just change the below-mentioned:

Before

import puppeteer from 'puppeteer';

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();

// Remember to catch errors and close!
})();

Before

import puppeteer from 'puppeteer';

(async () => {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://chrome-us.browsercloud.io?token=MY-TOKEN`,
});
const page = await browser.newPage();

// Remember to catch errors and close!
})();

Launch options

In the browserWSEndpoint there is an opportunity to detail launch-arguments through query-string parameters. So, specify it the way shown below in case you need to launch the browser with the pre-determined height and width:

Setting width and height

import puppeteer from 'puppeteer';

(async () => {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://chrome-us.browsercloud.io?token=MY-TOKEN&--window-size=1200,900`,
});
const page = await browser.newPage();

// Remember to catch errors and close!
})();