Playwright: [Feature] Do not require waiting for navigation upon click

Created on 3 Mar 2020  路  7Comments  路  Source: microsoft/playwright

The following pattern needs to go before we hit v1.0

const [response] = await Promise.all([
  page.waitForNavigation(waitOptions),
  page.click(selector, clickOptions),
]);

it should be simply

await page.click(selector, clickOptions);

Most helpful comment

This is now done, with waitUntil as @jperl was suggesting. I also pulled press into page.press() for convenience.

All 7 comments

I hope this will be true for all action methods. For example, if you press enter and it causes a page navigation.

One idea, is that all actions have option.waitUntil to wait for resulting page navigations and defaults to load.

Yes, action methods on page, frame and elementHandle and even evaluate. Not the page.keyboard / page.mouse ones though.

No plans for waitUntil for now - we consider waiting until certain load phase overvalued - it does not give much. It might change though and we fall back to having it.

A lot of times you press enter to submit a form (log in etc). It would be nice to auto-wait for press("Enter").

This is now done, with waitUntil as @jperl was suggesting. I also pulled press into page.press() for convenience.

@pavelfeldman Should this change warrant an update in this example, so people are not fooled into thinking this pattern is still needed? See https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitfornavigationoptions

And another question. page.waitForNavigation() waits for the load event whereas for page.click()you chose the event waitForNavigation - was there a reason? Reason I am asking is that in my case I could not replace the original post 1-to-1 with the new implementation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jperl picture jperl  路  3Comments

saltyshiomix picture saltyshiomix  路  3Comments

KevinGrandon picture KevinGrandon  路  4Comments

etnbrd picture etnbrd  路  4Comments

VikramTiwari picture VikramTiwari  路  4Comments