File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1
1
# playwright-aws-lambda
2
+
3
+ Support for PlayWright running on AWS Lambda and Google Cloud Functions
4
+
5
+ ## Install
6
+
7
+ ``` shell
8
+ npm install playwrite-core playwright-aws-lambda --save
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ This package works with the ` nodejs8.10 ` , ` nodejs10.x ` and ` nodejs12.x ` AWS
14
+ Lambda runtimes out of the box.
15
+
16
+ ``` javascript
17
+ const playwright = require (' playwright-aws-lambda' );
18
+
19
+ exports .handler = async (event , context ) => {
20
+ let result = null ;
21
+ let browser = null ;
22
+
23
+ try {
24
+ const browser = await playwright .launchChromium ();
25
+ const context = await browser .defaultContext ();
26
+
27
+ const page = await context .newPage ();
28
+ await page .goto (event .url || ' https://example.com' );
29
+
30
+ console .log (' Page title: ' , await page .title ());
31
+ } catch (error) {
32
+ throw err;
33
+ } finally {
34
+ if (browser !== null ) {
35
+ await browser .close ();
36
+ }
37
+ }
38
+ };
39
+ ```
40
+
41
+ ## Thanks / Credits
42
+
43
+ This project is based on the work of
44
+ [ chrome-aws-lambda] ( https://github.com/alixaxel/chrome-aws-lambda ) .
You can’t perform that action at this time.
0 commit comments