Skip to content

Commit

Permalink
Update waitforfunction.js to async check
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Sep 27, 2024
1 parent adcb65f commit 18eb2dd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions examples/waitforfunction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { check } from 'k6';
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: {
Expand Down Expand Up @@ -30,11 +30,16 @@ export default async function() {
}, 1000);
});

const ok = await page.waitForFunction("document.querySelector('h1')", {
polling: 'mutation',
timeout: 2000,
await check(page, {
'waitForFunction successfully resolved':
p => p.waitForFunction(
"document.querySelector('h1')", {
polling: 'mutation',
timeout: 2000
})
.then(e => e.innerHTML())
.then(text => text == 'Hello')
});
check(ok, { 'waitForFunction successfully resolved': ok.innerHTML() == 'Hello' });
} finally {
await page.close();
}
Expand Down

0 comments on commit 18eb2dd

Please sign in to comment.