Skip to content

Commit ba9b47e

Browse files
authored
[Checkly] adds "Browser Check #1" code
1 parent 9dac9f7 commit ba9b47e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

__checks__/browser-check-1.check.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy