Passing cookies and waiting for selector

Viewed 49

I have two problems with my script. The first one is it's sometimes so fast with logging in that going to another page afterwards is broken, how can I fix this? Sometimes I have to re-run the script in the hope it will pass the cookies. The second issue what I have is that it's not waiting for the selector and not clicking on it as well.

 numb
1 Answers

Documentation suggests to do this when logging in:

await Promise.all([
  page.waitForNavigation(), // The promise resolves after navigation has finished
  page.click('a.my-link'), // Clicking the link will indirectly cause a navigation
]);

The second issue what I have is that it's not waiting for the selector and not clicking on it as well.

The element is probably not present on the page, or the target page is not what you expect it to be. Be sure to check with screenshots and/or headful mode.

Related