Giter VIP home page Giter VIP logo

Comments (6)

aslushnikov avatar aslushnikov commented on May 2, 2024 7

We've spent some time discussing this and here's what we've agreed upon so far:

await page.waitFor(1000); // to wait for 1000ms
await page.waitFor('body div'); // to wait for the 'body div' selector in body
await page.waitFor(() => Math.random() < 0.5); // to wait for the predicate

await page.waitForSelector('body div'); // the same as page.waitFor('body div')
// wait for the 'body div' to be present and visible in the page:
await page.waitForVisible('body div');

from puppeteer.

aslushnikov avatar aslushnikov commented on May 2, 2024 4

Since page.waitFor should timeout after some time, and since the timeout should be customizable, the page.waitFor will have an options object:

await page.waitFor('body div', {timeout: 10000}); // timeout after 10s
await page.waitFor('body div', {visible: true}); // wait for element to be present and visible

from puppeteer.

JakubMatyka avatar JakubMatyka commented on May 2, 2024 4

I stuck on scenario when modal occurs and a button should be clicked. page.waitForSelector with flag visible: true does not work in this situation. The only way is to set timeout but I hate those

from puppeteer.

JoelEinbinder avatar JoelEinbinder commented on May 2, 2024

Just for reference, Nightmare has a generic .wait method that takes a number, selector, or function. It polls every 250ms to see if that function returns true, or if there is an element matching that selector.

from puppeteer.

jenni avatar jenni commented on May 2, 2024

Any news about...?

// wait for the 'body div' to be present and visible in the page:
await page.waitForVisible('body div');

This would be a great addition.

from puppeteer.

aslushnikov avatar aslushnikov commented on May 2, 2024

@Jen-V you can already use the visible option in page.waitForSelector method

from puppeteer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.