Example URL: https://unifiedportal-mem.epfindia.gov.in/memberinterface/ From this click on Forgot Password then Input UAN as: 101010101010 type captcha and submit.
How to obverse page didFinish on this? How to get the message "UAN is not Active" which comes after loading.
This didFinish function of webView doesn't work in this scenario as page is already loaded.
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!{
}
Tried below way but no response. Got this
Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}
let s = """
var open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener("load", function() {
var message = {"status" : this.status, "responseURL" : this.responseURL}
webkit.messageHandlers.handler.postMessage(message);
});
open.apply(this, arguments);
};
"""
weakSelf.webView.configuration.userContentController.removeScriptMessageHandler(forName: "myInterface") // to delete existing
weakSelf.webView.configuration.userContentController.add(weakSelf as WKScriptMessageHandler, name: "myInterface")
weakSelf.webView?.evaluateJavaScript(s, completionHandler: {(string,error) in
print(error ?? "no error")
})