waitFor throws misleading error on invalid selector
See original GitHub issueWhen 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:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top 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 >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
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
Thanks for the comprehensive review @benjaminlaib, your comment is completely right,I’ve reopened this issue