1

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")
                        })
Nitesh
  • 1,564
  • 2
  • 26
  • 53
  • 1
    upon clicking on submit it sends ajax request and get html data as response. have a look at https://stackoverflow.com/a/28828451/2299040 it tries to achieve similar to what you want – Sahil Manchanda Oct 22 '18 at 16:06
  • 1
    I was looking at the code. You need to call the callback in didFinish as when you click on Forgot Password it redirects you to another page. and about the error you are getting. try using https://stackoverflow.com/a/5202999/2299040 I tested the website with the code in the link Using Safari Developer option and it reports callback on every ajax. – Sahil Manchanda Oct 24 '18 at 18:34
  • 1
    @SahilManchanda Thanks got it done. – Nitesh Oct 24 '18 at 19:03
  • Cool, Please post the answer so that other could benefit if they ran into same problem :) – Sahil Manchanda Oct 25 '18 at 04:13

0 Answers0