question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi!

Is it possible to somehow stop (set a pause) the script. For example, when a modal window appears, stop the script execution, while closing the window, then defrost the script. I try this:


await page.waitForSelector('div[class="popup _active"]').then(async()=>{

	console.log('catch popup');

	page.click('span[class="submit"]').then(()=>{
		console.log('click confirm');
	});

	await page.waitForSelector('div[class="popup _active"]',{hidden:true}).then(()=>{
		console.log('el hidden');
	});
});

But it does not freeze script.

Is it possible to implement without using flags to make the script more flexible?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Mar 15, 2019

Sure, I’ll close this for now. Feel free to re-file with more details if you continue to experience issues.

1reaction
aslushnikovcommented, Mar 3, 2019

I’ll explain now. In the block where the button is pressed further, the waiting time is set. Because when the cycle starts again, the page does not have time to load and the condition of pressing the button works again (ie, the product is parsed again from the first page). You can comment out waitForNavigation because if you leave only it, the script hangs after clicking on the button next, and waitForNavigation does not see the page load.

@Trahtenberg I’d appreciate an explanation in layman terms that doesn’t refer to code - to help us understand what’s going on.

Now the question itself is how to organize the script in such a way that, using the minimum, waitFor(seconds)?

if you’re testing your own website, then I’d recommend set up certain hooks on the page that help you test it. The usual practice is to use data attributes on elements and then wait/query for them with page.waitForSelector/page.$. Other nice approach is to use console.timeStamp to yield certain events - you can listen to them on the puppeteer side using page.on('metrics') event.

If you’re dealing with a website as a black box, then there’s no silver bullet and all solutions vary a lot in creativity. Sometimes tracking certain network requests using page.on('requestfinished') works nicely, sometimes there’s a specific DOM element that you can wait for.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frozen script - The Internet Movie Script Database (IMSDb)
FROZEN Written by Jennifer Lee Final Shooting Draft 9/23/13 OPEN ON: ICE. We're underwater looking up at it. A saw cuts through, heading...
Read more >
Frozen (2013)/Transcript | Moviepedia - Fandom
Transcript. [first lines; a group of mountain men are saw through a frozen lake singing "Frozen Heart"]; Ice Harvesters: Born of cold and...
Read more >
Frozen Script PDF Download: Songs, Quotes, and Ending
Frozen • Let It Go · “You can't marry a man you just met.” · “Ice is my life!” · “I could kiss...
Read more >
Frozen Movie Script - Scripts.com
Synopsis: When their kingdom becomes trapped in perpetual winter, fearless Anna (Kristen Bell) joins forces with mountaineer Kristoff ...
Read more >
Frozen-Jr- Master-Script.pdf - Myart.org
Frozen JR. Script. Let the Sun Shine On...... A Little Bit of You..
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found