-
Notifications
You must be signed in to change notification settings - Fork 0
/
hybrid-test.js
47 lines (40 loc) · 972 Bytes
/
hybrid-test.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
45
46
47
import { chromium } from 'k6/experimental/browser';
import { check } from 'k6';
import http from 'k6/http';
export const options = {
scenarios: {
browser: {
executor: 'constant-vus',
exec: 'browser',
vus: 10,
duration: '10s',
},
news: {
executor: 'constant-vus',
exec: 'news',
vus: 20,
duration: '1m',
},
},
};
export async function browser() {
const browser = chromium.launch({ headless: false });
const page = browser.newPage();
try {
await page.goto('https://test.k6.io/browser.php');
page.locator('#checkbox1').check();
check(page, {
'checkbox is checked':
page.locator('#checkbox-info-display').textContent() === 'Thanks for checking the box',
});
} finally {
page.close();
browser.close();
}
}
export function news() {
const res = http.get('https://test.k6.io/news.php');
check(res, {
'status is 200': (r) => r.status === 200,
});
}