How to get results from Page.executeJavaScript

Are there any ways to get the execution results of javascript codes run by Page.executeJavaScript()?

Best regards,


Getting a return value directly from the execution call is not possible as noted in the documentation The script is executed asynchronously, so you can’t directly pass values back to the server.

But the executed script can call a method on the server to which it can send the result to.
This means that on the server you need to have a ClientCallable method e.g.

private void windowResized(int width, int height) {

And in the javascript when you have the result call in this instance

$0.$server.windowResized(document.body.clientWidth, document.body.clientHeight);
  • Mikael

Thanks a lot. Joey