Reputation: 5461
Say I have a UIwebview which shows a Login screen with username field, password field and a submit button.
Now when the webview is loaded, is it possible that I am able to populate the username and password fields from my code and finally call the submit button action (or say click the Submit button via code) . ?
Please provide some good references/
Upvotes: 1
Views: 1061
Reputation: 57060
Use the webview's stringByEvaluatingJavaScriptFromString:
to set values using Javascript and even simulate a button press.
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementById('loginId').value = '%@';document.getElementById('passwordId').value = '%@';document.getElementById('buttonId').click()", username, password]];
Make sure to escape the input correctly, or you may break the javascript.
Upvotes: 1