Skip to content

Commit

Permalink
Add a dispatch event example
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Feb 2, 2024
1 parent b78c0e5 commit 67133a3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/dispatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { check } from 'k6';
import { browser } from 'k6/x/browser';

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

export default async function() {
const context = browser.newContext();
const page = context.newPage();

try {
await page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });

page.locator('a[href="/contacts.php"]')
.dispatchEvent("click");

check(page, {
header: (p) => p.locator("h3").textContent() == "Contact us",
});
} finally {
page.close();
}
}

0 comments on commit 67133a3

Please sign in to comment.