clickAndWaitForNavigation method
Convenience function to wait for navigation to complete after clicking on an element.
See this issue for more context: https://github.com/GoogleChrome/puppeteer/issues/1421
Note: Be wary of ajax powered pages where the navigation event is not triggered.
await page.clickAndWaitForNavigation('input#submitData');
as opposed to:
await Future.wait([
page.waitForNavigation(),
page.click('input#submitData'),
]);
Implementation
Future<Response?> clickAndWaitForNavigation(String selector,
{Duration? timeout, Until? wait}) async {
var navigationFuture = waitForNavigation(timeout: timeout, wait: wait);
await click(selector);
return await navigationFuture;
}