-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
131a3ec
commit 87719e6
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { browser } from 'k6/x/browser/async'; | ||
import { check } from 'https://jslib.k6.io/k6-utils/1.5.0/index.js'; | ||
|
||
export const options = { | ||
scenarios: { | ||
ui: { | ||
executor: 'shared-iterations', | ||
options: { | ||
browser: { | ||
type: 'chromium', | ||
}, | ||
}, | ||
}, | ||
}, | ||
thresholds: { | ||
checks: ["rate==1.0"] | ||
} | ||
} | ||
|
||
export default async function() { | ||
let context = await browser.newContext({ | ||
userAgent: 'k6 test user agent', | ||
}) | ||
let page = await context.newPage(); | ||
await check(page, { | ||
'user agent is set': async p => { | ||
const userAgent = await p.evaluate(() => navigator.userAgent); | ||
return userAgent.includes('k6 test user agent'); | ||
} | ||
}); | ||
await page.close(); | ||
await context.close(); | ||
|
||
context = await browser.newContext(); | ||
check(context.browser(), { | ||
'user agent does not contain headless': b => { | ||
return b.userAgent().includes('Headless') === false; | ||
} | ||
}); | ||
|
||
page = await context.newPage(); | ||
await check(page, { | ||
'chromium user agent does not contain headless': async p => { | ||
const userAgent = await p.evaluate(() => navigator.userAgent); | ||
return userAgent.includes('Headless') === false; | ||
} | ||
}); | ||
await page.close(); | ||
} |