This is a summary of a Playwright Testing tutorial that explains how to run Playwright tests on cloud-based browsers.
To install Playwright, all you need to do is run this command:npm i --save playwright
Once you have Playwright installed, you can run your first test on a remote browser.
Simply use the following code to run a simply Playwright script on a remote browser on TestingBot:const pw = require('playwright-core');
(async () => {
const browser = await pw.chromium.connect({
wsEndpoint: 'wss://cloud.testingbot.com/playwright?key=&secret=&browserName=chrome&browserVersion=latest',
});
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://testingbot.com/');
await page.screenshot({ path: 'screenshot.png' });
await browser.close();
})();
This will start a new Chrome browser, instruct it to open a URL, take a screenshot of the page and finally close the browser.
Of course this is a very simple example. There are many other options you can use, including Visual Regression Testing with Playwright.