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);
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.
Most helpful comment
This is now done, with
waitUntilas @jperl was suggesting. I also pulled press intopage.press()for convenience.