Skip to content

Instantly share code, notes, and snippets.

@dgzlopes
Last active March 13, 2023 13:00
Show Gist options
  • Save dgzlopes/f083f931655ec8fe3eb0d24f974ac900 to your computer and use it in GitHub Desktop.
Save dgzlopes/f083f931655ec8fe3eb0d24f974ac900 to your computer and use it in GitHub Desktop.
import { check } from 'k6';
import http from 'k6/http';
import { page } from 'k6/experimental/browser';
export const options = {
scenarios: {
browser: {
executor: 'constant-vus',
exec: 'browser',
vus: 1,
browser: {
type: 'chromium',
headless: false,
context: {
width: 1920,
height: 1080,
}
},
duration: '10s',
},
news: {
executor: 'constant-vus',
exec: 'news',
vus: 20,
duration: '1m',
},
},
};
export async function browser() {
await page.goto('https://test.k6.io/browser.php', { waitUntil: 'networkidle' });
page.locator('#checkbox1').check();
check(page, {
'checkbox is checked': page.locator('#checkbox-info-display').textContent() === 'Thanks for checking the box',
});
page.close();
}
export function news() {
const res = http.get('https://test.k6.io/news.php');
check(res, {
'status is 200': (r) => r.status === 200,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment