Generalize page.waitFor, make waitForSelector a utility on top of it.
See original GitHub issueRationale: waitForSelector is rarely useful on its own. I have a DOM element, but it is off screen / display:none, etc.
We can make waitFor generic and execute it either upon every task (by default) or upon tasks that had specific activities in them (optional).
utilitites.waitForSelector = (selector) => {
return page.waitFor(() => document.querySelector(selector), ['style'], selector);
}
utilitites.waitForLayout = () => {
return page.waitFor(() => true, ['layout']);
}
utilitites.waitForFrame = () => {
return page.waitFor(() => true, ['frame']);
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Page.waitForSelector() method
Wait for the selector to appear in page. If at the moment of calling the method the selector already exists, the method will...
Read more >puppeteer: how to wait until an element is visible?
I think you can use page.waitForSelector(selector[, options]) function for that purpose. const puppeteer = require('puppeteer'); ...
Read more >puppeteer.Page.waitForSelector JavaScript and Node.js ...
Best JavaScript code snippets using puppeteer.Page.waitForSelector(Showing top 15 results out of 315) ; "[name='username']" ; }); await page.keyboard.press(' ...
Read more >React Testing Library
The React Testing Library is a very light-weight solution for testing React components. It provides light utility functions on top of react-dom ...
Read more >Getting to Know Puppeteer Using Practical Examples
Makes the browser to be launched in a headful way ... Option 2 - if we have a page instance, just using `waitFor`....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ve spent some time discussing this and here’s what we’ve agreed upon so far:
I stuck on scenario when modal occurs and a button should be clicked.
page.waitForSelector
with flagvisible: true
does not work in this situation. The only way is to set timeout but I hate those