You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it stands, you can pass a command as a string to evaluatePage where that command returns an object, eg:
awaitsinco.evaluatePage(`document.querySelector('a').getBoundingClientRect()`)// the command in the dom returns an obj
But the value property doesnt exist on the response. I think i've seen this before, if a command that returns an object is passed to Runtime.evaluate wont return anything
What I propose is we investigate using Runtime.callFunctionOn for both strings AND functions, but this needs ot be tested to see if we cna do that. For example im thinking:
evaluate(command: str|Function){// Logic for handling if a string will be removedif(commandisa string)command=()=>command// Then existing logicconst{ executionContextId }=awaitthis.sendWebSocketMessage("Page.createIsolatedWorld",{frameId: this.frame_id,},);const{ result }=awaitthis.sendWebSocketMessage("Runtime.callFunctionOn",{functionDeclaration: pageCommand.toString(),executionContextId: executionContextId,returnByValue: true,awaitPromise: true,userGesture: true,},);returnresult.value;}evaluate(doc.querySelector(selector))
Why:
I think it's just a limitation of that runtime method
Acceptance Criteria
Below is a list of tasks that must be completed before this issue can be closed.
Write tests for ensuring we can return an object from the evaluatePage method
The text was updated successfully, but these errors were encountered:
I've investigated, and found that there isn't anything we can do. Thats just the nature of the API, it won't return class based objects, BUT it would return a pure object, eg something.toJson() or { name: 2 }.
Tested with puppeteer, and i experienced the same thing
Summary
What:
As it stands, you can pass a command as a string to
evaluatePage
where that command returns an object, eg:But the
value
property doesnt exist on the response. I think i've seen this before, if acommand
that returns an object is passed toRuntime.evaluate
wont return anythingWhat I propose is we investigate using
Runtime.callFunctionOn
for both strings AND functions, but this needs ot be tested to see if we cna do that. For example im thinking:Why:
I think it's just a limitation of that runtime method
Acceptance Criteria
Below is a list of tasks that must be completed before this issue can be closed.
The text was updated successfully, but these errors were encountered: