Playwright
Playwright is a brand new Microsoft's cross-browser library supported by pw.chromium.connect method
. Playwright assists cross-browser testing and development. At present only chromium
is ready to use, though other browsers are also considered by us. Note that two alternative methods of connection through playwright, with their pros and cons, are supported by BrowserCloud. All in all, look at these API methods:
playwright.chromium.connect(wsEndpoint: string)
To manage the connection the 'connect' common method (which is fast and fully-featured, therefore supports many playwright parameters such as proxi using a proxy etc.) uses playwright's built-in browser-server. Unfortunately, ad-blocking and stealth aren't provided as in this case playwright using is demanded. Integration with connectOverCDP
is to be considered to activate the above-mentioned options.
Take a screenshot in playwright
const pw = require('playwright');
(async () => {
const browser = await pw.chromium.connect('wss://chrome-v2.browsercloud.io/playwright?token=API-TOKEN');
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://www.example.com/');
await page.screenshot({ path: 'example.png' });
await browser.close();
})();
playwright.chromium.connectOverCDP(wsEndpoint: string)
Playwright can connect through the Chrome's DevTools Protocol with the connectOverCDP
endpoint assistance. Though it's similar to the way of puppeteer operation, sessions are more "chatty" over the network versus playwright's connect
, so it leads to a little performance hit. One of our built-in helpers such as ad-blocking or your session stealth can be used as playwright is similar to puppeteer. Use the connect
method in case you need to work with playwright's proxy helper.
Take a screenshot in playwright
const pw = require('playwright');
(async () => {
const browser = await pw.chromium.connectOverCDP('wss://chrome-v2.browsercloud.io?token=API-TOKEN');
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://www.example.com/');
await page.screenshot({ path: 'example.png' });
await browser.close();
})();
The same puppeteer launch arguments can be used with playwright
and connectOverCDP
.
Time to scale out your playwright apps as well as to use APIs and helper functions right through BrowserCloud!