Puppeteer How to stop the js script if url changes

Viewed 21

Hello i have a small problem with puppeteer , iam working on site that sometimes changing the url while i do puppeteer function like typing or click on some elements so how can I catch the request change and stop the script ?

My code is something like this

await page.keyboard.type(“bla bla bla”)

So while puppeteer type on the page the url changes and puppeteer make an error and the other functions after page type keep going. I just wanna tell puppeteer if u type on page and the request url includes a word like “error” at any point of code event u didn’t finish your async function i wanna u to stop the whole script or the whole function and return anything like “false”

I used page.on to capture the url change but still can’t stop the whole script if the url change

0 Answers
Related