123456789101112131415161718192021222324252627282930313233 |
- import { browser } from 'k6/browser';
- export const options = {
- scenarios: {
- ui: {
- executor: 'shared-iterations',
- vus: 1, // 使用5个虚拟用户
- iterations: 1,
- options: {
- browser: {
- type: 'chromium',
- }
- },
- },
- },
- thresholds: {
- checks: ['rate==1.0'],
- }
- };
- export default async function () {
- const targetUrl = __ENV.targetUrl || 'http://www.baidu.com';
- const timeStamp = __ENV.timeStamp || '1751936544346';
- const page = await browser.newPage();
- // const targetUrlWithoutProtocol = targetUrl.replace('http://', '');
- // targetUrlWithoutProtocol = targetUrlWithoutProtocol.replace('https://', '');
- try {
- await page.goto(targetUrl);
- await page.screenshot({ path: `screenshots/screenshot_${timeStamp}.png` });
- } finally {
- await page.close();
- }
- }
|