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.

Smart Wait with puppeteer

See original GitHub issue

What are you trying to achieve?

Define Smart waits using puppeteer

What do you get instead?

I need to set wait on each statement

Provide console output if related. Use --verbose mode for more details.

# paste output here

Provide test source code if related

// paste test

Details

  • CodeceptJS version:
  • NodeJS Version:
  • Operating System:
  • Protractor || WebDriverIO || Nightmare version (if related)
  • Configuration file:
# paste suite config here

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DavertMikcommented, Oct 23, 2018

Cool. Thank you.

Let me write here the ideas behind SmartWait:

SmartWait was created because there was implicit wait API in WebDriver. https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp So basically it works by turning on/off implicit waits when a CSS/XPath selector is searched.

However, for Puppeteer there is no such API so this functionalioty should be implemented manually.

SmartWait works only for CSS/XPath locators, because when we do fuzzy search we try different locators. So a link or button is not found we should search by image inside a link, span inside link, etc. So you can make few empty tries before getting a valid result. So SmartWait should not work for fuzzy locators.

You can use either promise-retry library or setInterval to make a poll for a new elements.

A basic example.

// inside findClickable: 

if (!matchedLocator.isFuzzy()) {
    // make a poll and when element is found return it
    // return findElements.call(this, contextEl, matchedLocator.simplify());
  }

0reactions
DavertMikcommented, Sep 5, 2021

I don’t think it is needed with retryFailedStep plugin

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoiding hard waits in Playwright and Puppeteer
Explicit waits are a type of smart wait we invoke explicitly as part of our script. We will want to use them more...
Read more >
Smart Wait with puppeteer · Issue #1277 · codeceptjs ... - GitHub
Define Smart waits using puppeteer What do you get instead? I need to set wait on each statement Provide console output if related....
Read more >
Avoiding hard waits - Checkly
Both Puppeteer and Playwright offer many different kinds of smart waits, but Playwright takes things one step further and introduces an auto-waiting ......
Read more >
puppeteer waits for first element to load - Stack Overflow
If you want to set a timeout, I would do it in the page.waitForSelector in Puppeteer. await page.goto('https://stackoverflow.com/questions/ ...
Read more >
Testing with Puppeteer - A Complete Guide - HeadSpin
log(err); } finally { await browser.close(); } })();. In the code above, we are using Puppeteer to test the title of the web...
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