Skip to content

[Feature] waitForURL #5896

@srguiwiz

Description

@srguiwiz

Documentation at https://playwright.dev/docs/navigations says

// Note that Promise.all prevents a race condition
// between clicking and waiting for a navigation.
await Promise.all([
  page.waitForNavigation(), // Waits for the next navigation
  page.click('a'), // Triggers a navigation after a timeout
]);

That causes unfortunate extra noise in our effort of accommodating the whole spectrum of people involved.

This feature request suggests allowing

await page.click('a');
await page.waitForURL(urlMatch); // same as in WaitForNavigationOptions

The waitForURL method should return immedaitely if already at the URL, else invoke waitForNavigation.

As mentioned at https://playwright.dev/docs/api/class-page#pageclickselector-options for the click method

Wait for initiated navigations to either succeed or fail, unless noWaitAfter option is set.

is good, but apparently not sufficient to cover all cases.

Most importantly, per this feature request, resulting coding style would become easier to maintain.

Probably should be implemented in https://github.com/microsoft/playwright/blob/master/src/client/frame.ts .

This feature request adds information that possibly hadn't been available yet earlier for #2142 .

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions