Skip to content

Commit 0a48f4d

Browse files
committed
Update browser test
1 parent c1cdb78 commit 0a48f4d

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

dev/browser.js

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { check } from 'k6'
12
import { browser } from 'k6/browser'
23

34
export const options = {
@@ -11,15 +12,31 @@ export const options = {
1112
},
1213
},
1314
},
15+
thresholds: {
16+
checks: ['rate==1.0'],
17+
},
1418
}
1519

1620
export default async function () {
17-
const page = browser.newPage()
21+
const page = await browser.newPage()
1822

1923
try {
20-
await page.goto('https://test.k6.io/')
21-
page.screenshot({ path: 'screenshots/screenshot.png' })
24+
await page.goto('https://quickpizza.grafana.com/admin')
25+
26+
await page.locator('input[name="username"]').fill('admin')
27+
await page.locator('input[name="password"]').fill('admin')
28+
29+
await page.waitForLoadState('networkidle') // waits until the `networkidle` event
30+
31+
await page.locator('button[type="submit"]').click()
32+
33+
const label = await page.locator('h2')
34+
const textContent = (await label.textContent()).trim()
35+
36+
check(textContent, {
37+
header: (t) => t === 'Latest pizza recommendations',
38+
})
2239
} finally {
23-
page.close()
40+
await page.close()
2441
}
2542
}

0 commit comments

Comments
 (0)