Skip to content

Commit

Permalink
Update and fix the example browser test
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Mar 27, 2024
1 parent b17d645 commit ba63df0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions examples/experimental/browser.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { check } from 'k6';
import { chromium } from 'k6/experimental/browser';
import { browser } from 'k6/experimental/browser';

export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
thresholds: {
checks: ["rate==1.0"]
}
}

export default async function() {
const browser = chromium.launch({
headless: __ENV.XK6_HEADLESS ? true : false,
});
const context = browser.newContext();
const page = context.newPage();

Expand All @@ -32,10 +39,9 @@ export default async function() {
page.locator('input[type="submit"]').click(),
]);
check(page, {
'header': page.locator('h2').textContent() == 'Welcome, admin!',
'header': p => p.locator('h2').textContent() == 'Welcome, admin!',
});
} finally {
page.close();
browser.close();
}
}

0 comments on commit ba63df0

Please sign in to comment.