.waitForFunction() should return a value
See original GitHub issueIt seems that as for now, .waitForFunction()
just checks for the truthiness of the returned value in the frame context, which is then discarded. It is impossible to implement any functionality that waits for the function’s Promise actually returning a value and using that value in the Node context.
One possible scenario would be using .waitForFunction
to wait for a specific <option>
tag with a specific label and returning instead its value.
I could simulate it with .evaluate()
but I would lose the polling/timeout configuration options.
Version: 1.0.0-rc
Platform: Linux
NodeJS:: v9.x
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
Pass a function inside page.waitForFunction() with puppeteer
waitForFunction() accepts a callback and right now you're passing in a ... This results in the return value of the callback (a boolean ......
Read more >Puppeteer waitForFunction - tools4testing
waitForFunction method waits till the supplied function evaluates to true. waitForFunction method returns the promise with the JSHandle of the truthy value.
Read more >puppeteer.Page.waitForFunction JavaScript and Node.js code ...
Allows waiting for various conditions. Most used puppeteer functions. launch. The method launches a browser instance with given arguments. The browser will be ......
Read more >Page.waitForFunction() method - Puppeteer
waitForFunction() can be used to observe viewport size change: import puppeteer from 'puppeteer'; (async () => { const browser = await puppeteer.launch();
Read more >Puppeteer documentation - DevDocs
If no element matches the selector, the return value resolves to null . ... waitForFunction(). if selectorOrFunctionOrTimeout is a number , then the...
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
@yujiosaka Actually,
.waitForXPath
was the thing I was missing at the beginning. Then, trying some hacks and workarounds, I came up with this question. But yes, it could solve some scenarios.It is very common to do tests or scraping based on the presence of some inner HTML and not a tag, class or id by itself.
@yujiosaka but your
label
attribute makes no sense, it should bevalue
, with label I am referring to theinnerHTML
of theoption
. Which is impossible to check via selectors.Practical example: a page is loaded with a
select
tag. The dropdown is filled via AJAX with someoption
tags like:I have to intercept the option whose
innerHTML
isFoo
and retrieve its value (45
). I’d expect to do something like:This would be super because I can pass arguments and specify polling type and timeout. But I have to do some serious hacks to retrieve that value.
This is only a particular case, anyway.