Signal when QWebEngineView or its page have completed execution of page JavaScripts?



  • I am exploring using QWebEngineView to render a particular webpage that contains some JavaScript that alter the page's DOM. When fully rendered I want to print the page. The page loads just fine and the javascripts executes automatically.

    I can use the loadFinished() signal to tell when the page is loaded, but I wonder if there is a way to tell when also the javascript has been fully executed?

    I am currently using Qt 5.8 and the minimal webenginewidget example as a base.



  • There is no such thing as "the java-script has been fully executed".
    If you don't think so - please define when "the java-script has been fully executed"

    That's why we have to do with loadFinished() only at least that's a known event. One possible workaround is (if java-script modifies DOM to wait for these modifications to appear - try to detect using XPath/CSS and then emit your own signal)
    NB! Due to its asynchronous nature there is no guarantee that's the last script executed!



  • Thanks for the informative points. What I had in mind, that potentially could define "fully executed" is that the script interpreter, in case there are no infinite loops etc, has reached the last line of code for all (or each) scripts on the page. But as you point out that might be a bit naive.

    In my case I do have control over the page to be rendered, so having a hidden DOM element saying "done", or changing the title for which there is a signal already, would work.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.