Skip to content

Commit

Permalink
Update keyboard JS examples for async
Browse files Browse the repository at this point in the history
Also fixes a race condition by adding waitForNavigation.
  • Loading branch information
inancgumus committed May 8, 2024
1 parent f20b7c9 commit 099a6a4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions examples/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ export default async function () {
const page = await browser.newPage();

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

const userInput = page.locator('input[name="login"]');
await userInput.click();
page.keyboard.type('admin');
await page.keyboard.type("admin");

const pwdInput = page.locator('input[name="password"]');
await pwdInput.click();
page.keyboard.type('123');
await page.keyboard.type("123");

await page.keyboard.press('Enter'); // submit
await page.waitForNavigation();

page.keyboard.press('Enter'); // submit

await page.close();
page.close();
}

0 comments on commit 099a6a4

Please sign in to comment.