Home Saved data on device to autofill forms through WKWebView using Javascript, AngularJS
Reply: 0

Saved data on device to autofill forms through WKWebView using Javascript, AngularJS

user1528
1#
user1528 Published in May 23, 2018, 10:40 pm

Let me say this first: I'm not the best in HTML, Javascript or Angular.js

I am using Swift 4 and iOS WKWebView in Xcode to go to specific commercial websites and when a user saves his login information to their iOS device (email and password), it populates those fields and submits. I know there are other options for autofilling fields, but I need to do it this way given the project I'm working on.

I autofill the login by using the textfield's ids like this:

webView.evaluateJavaScript("document.getElementById('email').value = 'example@email.com';", completionHandler: nil)

This method works with basic forms, but with more complex forms it seems (it's using AngularJS Form Validation I believe), you can't just do an autofill and push submit. It'll say this:

I noticed that if you type then delete a random letter into each field after they have been autofilled, the form recognizes the fields as being filled correctly. I think it's because they have the fields as being "required," and normally an input/change event occurs on the website to recognize input in the textfields (just a guess).

And if that's the case, then would I need to locate the specific event(though I've tried and am having trouble locating it in the html) or would I be able to fire off a synthetic event(?) somehow using the "evaluateJavaScript" method?

If anyone could help me with this issue, I would seriously appreciate it.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302354 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO