-
Notifications
You must be signed in to change notification settings - Fork 7
/
simple-browser.js
44 lines (37 loc) · 1.08 KB
/
simple-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { browser } from 'k6/experimental/browser';
import { check } from 'k6';
export const options = {
scenarios: {
ui: {
executor: 'constant-vus',
exec: 'browsertest',
vus: 4,
duration: '30s',
gracefulStop: '0s',
options: {
browser: {
type: 'chromium',
},
},
},
},
thresholds: {
checks: ["rate==1.0"]
}
}
export async function browsertest() {
const context = browser.newContext();
const page = context.newPage();
try {
await page.goto('https://test.k6.io/my_messages.php');
page.locator('input[name="login"]').type('admin');
page.locator('input[name="password"]').type('123');
const submitButton = page.locator('input[type="submit"]');
await Promise.all([page.waitForNavigation(), submitButton.click()]);
check(page, {
'header': p => p.locator('h2').textContent() == 'Welcome, admin!',
});
} finally {
page.close();
}
}