0.4.0 • Published 4 years ago

@eddiewang/playwright-aws-lambda v0.4.0

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

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 / PropertyReturnsDescription
launchChromium{!Promise<playwright.ChromiumBrowser>}Launches the Chromium browser.

Thanks / Credits

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