Skip to content

Commit

Permalink
Update fillform.js for locator async
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed May 14, 2024
1 parent 2679cf9 commit a99f749
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/fillform.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ export default async function() {
page.waitForNavigation(),
page.locator('a[href="/my_messages.php"]').click(),
]);

// Enter login credentials and login
page.locator('input[name="login"]').type('admin');
page.locator('input[name="password"]').type('123');
await page.locator('input[name="login"]').type('admin');
await page.locator('input[name="password"]').type("123");

// We expect the form submission to trigger a navigation, so to prevent a
// race condition, setup a waiter concurrently while waiting for the click
// to resolve.
await Promise.all([
page.waitForNavigation(),
page.locator('input[type="submit"]').click(),
]);
check(page, {
'header': p => p.locator('h2').textContent() == 'Welcome, admin!',
});

const h2 = page.locator('h2');
const headerOK = await h2.textContent() == 'Welcome, admin!';
check(headerOK, { 'header': headerOK });

// Check whether we receive cookies from the logged site.
check(await context.cookies(), {
Expand Down

0 comments on commit a99f749

Please sign in to comment.