Jump to content

[Swift] Wait for JS to fully evaluate before getting HTML

stephen_fung
 func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
	webView.evaluateJavaScript("document.documentElement.innerHTML.toString()", completionHandler: { (html: Any?, error: Error?) in
        print(html)
                })
        }

The HTML printed is before the Javascript is fully evaluated. Can someone tell me why? Is it because there are two javascript cycles? Is there a parameter for Javascript string that will allow me to see the fully rendered HTML?

 

URL being tested: https://www.fedex.com/apps/fedextrack/index.html?tracknumbers=74893150311361418402&cntry_code=us

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×