Can IJSHandle.EvaluateFunctionAsync return null ? #2808
Replies: 5 comments
-
I think Regarding this:
That's part of switching to |
Beta Was this translation helpful? Give feedback.
-
Yes it does. I'm mentioning it because I didn't catch an eye on anything that can return null while I was debugging. Basically |
Beta Was this translation helpful? Give feedback.
-
Do you have any example to look at? |
Beta Was this translation helpful? Give feedback.
-
I just rerun tests with conditional breakpoints and I didnt catch null result even once
While its all syntetic there is quite a set of tests and not a single time I catch To check just copy solution, put breakpoints on mentioned lines and run all tests I can try to aquire null result myself just to check if I'm wrong, but I need a hint how to do it as I'm not so deep into PuppeteerSharp library and dont know internals |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I'm trying to use PuppeteerSharp.Dom and I believe it takes parsing approach when it comes to returning generic values as evaluation results compared to PuppeteerSharp which consider original variable type from JS and throws when requesting something like int when evaluating result is not Number so I was updating repo and got a question
Here at line 71
IJSHandle.EvaluateFunctionAsync
is called which isTask<JsonElement?> EvaluateFunctionAsync(string script, params object[] args)
But while I was testing I didn't see result as null a single time. For example getting non-existent smth. returns JsonElement and at that point I'm not sure what then should return null.
Looks like it's a mistake and
JsonElement?
must be changed to justJsonElement
to remove confusionAnd while I'm at it - did I get it right about translating/parsing types from evaluation results to generic types? I run some tests to check
await page.EvaluateFunctionAsync<int>("() => '123'")
dont work butawait page.EvaluateFunctionAsync<int>("() => Number('123')")
worksBeta Was this translation helpful? Give feedback.
All reactions