Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
160 views
in Technique[技术] by (71.8m points)

node.js - Passing cookies and waiting for selector

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...