File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * This is a basic Playwright script to get you started!
3+ * To learn more about Browser checks and Playwright visit: https://www.checklyhq.com/docs/browser-checks
4+ */
5+
6+ // Create a Chromium browser
7+ const { chromium } = require ( 'playwright' )
8+
9+ // Checkly supports top level await, but we wrap your code in an async function so you can run it locally too.
10+ async function run ( ) {
11+ const browser = await chromium . launch ( )
12+ const page = await browser . newPage ( )
13+
14+ // We visit the page. This waits for the 'load' event by default.
15+ const response = await page . goto ( 'https://google.com' )
16+
17+ // If the page doesn't return a successful response code, we fail the check.
18+ if ( response . status ( ) > 399 ) {
19+ throw new Error ( `Failed with response code ${ response . status ( ) } ` )
20+ }
21+
22+ // We snap a screenshot.
23+ await page . screenshot ( { path : 'screenshot.jpg' } )
24+
25+ // We close the page to clean up and gather performance metrics.
26+ await page . close ( )
27+ await browser . close ( )
28+ }
29+
30+ run ( )
You can’t perform that action at this time.
0 commit comments