@eddiewang/playwright-aws-lambda

0.4.0 • Public • Published

playwright-aws-lambda

Support for PlayWright running on AWS Lambda and Google Cloud Functions.

NOTE: Currently only Chromium is supported.

Install

npm install playwrite-core playwright-aws-lambda --save

Usage

This package works with the nodejs8.10, nodejs10.x and nodejs12.x AWS Lambda runtimes out of the box.

const playwright = require('playwright-aws-lambda');

exports.handler = async (event, context) => {
  let result = null;
  let browser = null;

  try {
    const browser = await playwright.launchChromium();
    const context = await browser.defaultContext();

    const page = await context.newPage();
    await page.goto(event.url || 'https://example.com');

    console.log('Page title: ', await page.title());
  } catch (error) {
    throw err;
  } finally {
    if (browser !== null) {
      await browser.close();
    }
  }
};

API

Method / Property Returns Description
launchChromium {!Promise<playwright.ChromiumBrowser>} Launches the Chromium browser.

Thanks / Credits

This project is based on the work of chrome-aws-lambda.

Dependents (0)

Package Sidebar

Install

npm i @eddiewang/playwright-aws-lambda

Weekly Downloads

7

Version

0.4.0

License

MIT

Unpacked Size

57.7 MB

Total Files

27

Last publish

Collaborators

  • eddiewang