Support for running Microsoft's Playwrite on AWS Lambda and Google Cloud functions
npm install @oro-dxeco/playwright-aws-lambdashell
npm install playwright-core playwright-aws-lambda --save
`
Usage
This package works with the nodejs10.x, nodejs12.x, nodejs14.x, nodejs16.x, nodejs18.x, nodejs20.x and nodejs22.x AWS Lambda runtimes
out of the box.
`javascript
const playwright = require('playwright-aws-lambda');
exports.handler = async (event, context) => {
let browser = null;
try {
browser = await playwright.launchChromium();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(event.url || 'https://example.com');
console.log('Page title: ', await page.title());
} catch (error) {
throw error;
} finally {
if (browser) {
await browser.close();
}
}
};
`
API
| Method / Property | Returns | Description |
| ----------------- | ---------------------------------------- | ------------------------------------- |
| launchChromium | {!Promise | Launches the Chromium browser. |
| loadFont(url) | {Promise | Downloads and activates a custom font |
$3
If you need custom font support by e.g. emojicons in your browser, you have to
load it by using the loadFont(url: string) function before you launch the
browser.
`js
await loadFont(
'https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf'
);
``