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.

waitFor throws misleading error on invalid selector

See original GitHub issue

When waitFor(...) or any function using waitFor(...) is called with an invalid CSS selector, it will throw an error saying the timeout exceeded. The expected behavior would be a message saying that the CSS selector is invalid.

I am using wendigo@2.11.1.

Code to reproduce:

let browser
async function main () {
  browser = await wendigo.createBrowser({ headless: false })
  await browser.open('https://github.com')
  await browser.waitAndClick('invalid[selector')
}

main()
  .catch(console.error)
  .finally(() => browser && browser.close())

Result:

{ TimeoutError: waiting for selector "invalid[selector" failed: timeout 500ms exceeded
    at new WaitTask (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/DOMWorld.js:549:28)
    at DOMWorld._waitForSelectorOrXPath (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/DOMWorld.js:478:22)
    at DOMWorld.waitForSelector (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/DOMWorld.js:432:17)
    at Frame.waitForSelector (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/FrameManager.js:627:47)
    at Frame.<anonymous> (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/helper.js:112:23)
    at Frame.waitFor (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/FrameManager.js:612:19)
    at Page.waitFor (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/Page.js:1116:29)
    at PuppeteerPage.<anonymous> (/workspace/vuer_oss/node_modules/wendigo/dist/lib/puppeteer_wrapper/puppeteer_page.js:102:29)
    at Generator.next (<anonymous>)
    at /workspace/vuer_oss/node_modules/wendigo/dist/lib/puppeteer_wrapper/puppeteer_page.js:8:71
  -- ASYNC --
    at Frame.<anonymous> (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/helper.js:111:15)
    at Frame.waitFor (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/FrameManager.js:612:19)
    at Page.waitFor (/workspace/vuer_oss/node_modules/wendigo/node_modules/puppeteer/lib/Page.js:1116:29)
    at PuppeteerPage.<anonymous> (/workspace/vuer_oss/node_modules/wendigo/dist/lib/puppeteer_wrapper/puppeteer_page.js:102:29)
    at Generator.next (<anonymous>)
    at /workspace/vuer_oss/node_modules/wendigo/dist/lib/puppeteer_wrapper/puppeteer_page.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/workspace/vuer_oss/node_modules/wendigo/dist/lib/puppeteer_wrapper/puppeteer_page.js:4:12)
    at PuppeteerPage.waitFor (/workspace/vuer_oss/node_modules/wendigo/dist/lib/puppeteer_wrapper/puppeteer_page.js:101:16)
    at obj.<anonymous> (/workspace/vuer_oss/node_modules/wendigo/dist/lib/browser/mixins/browser_wait.js:44:34) name: 'TimeoutError' }

Fix:

Here it should not swallow err if err is not a timeout error. The same applies to every function using waitFor(...) (e.g. waitAndClick(...), waitUntilNotVisible(...), etc.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
angrykoalacommented, Jul 24, 2020

Hi @facusantillo no progress for now, the PR wasn’t updated so it was closed due to inactivity and I have not gotten around to fix this yet.

Sadly, I don’t think there is a viable workaround without actually fixing this in Wendigo. I’ll try to patch it around as soon as possible if this is generating so many problems, but I’m not sure when I’ll be able to fix this

PRs are welcome, the closed PR by @benjaminlaib is actually a good starting point

1reaction
angrykoalacommented, Feb 10, 2020

Thanks for the comprehensive review @benjaminlaib, your comment is completely right,I’ve reopened this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Explicit wait for a selector isn't working? - node.js
The page.waitForSelector statement is working. One of the page.click calls is the problem. Relevant part of the error message:
Read more >
How To Fix InvalidSelectorException In Selenium - YouTube
In this video, I will guide you how to fix selenium.common.exceptions. InvalidSelectorException in Selenium In this video, I will guide you ...
Read more >
Browser - MarketSquare
This method waits for an element matching the selector to appear, waits for actionability checks, focuses the element, fills it and triggers an ......
Read more >
Invalid selector - WebDriver - MDN Web Docs
The invalid selector error is a WebDriver error that occurs when an element retrieval command is used with an unknown web element selector...
Read more >
Page | Playwright - CukeTest
To wait for an element on the page, use page. ... If no elements match the selector, the method throws an error. ......
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