Reputation: 93
I am trying to fill in a few fields(Working) then click the login button(Not Working) I have tried:
document.getElementById('loginButton').click();"
and
document.forms['form'].submit();
The button name and form name are correct, what am I doing wrong?
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url)
{
webview.loadUrl("javascript:(function() { " +
"document.getElementById('coCode').value = 'CompanyCode';" +
"document.getElementById('loginName').value = 'LoginName';" +
"document.getElementById('password').value = 'Password';" +
//"document.forms['form'].submit();" + //Doesn't Work
//"document.getElementById('loginButton').click();" + //Doesn't Work
"})()");
}
});
Upvotes: 2
Views: 6609
Reputation: 93
I figured it out, the following worked for me:
webview.loadUrl("javascript:WebForm_DoPostBackWithOptions(
new WebForm_PostBackOptions('loginButton', '', true, '', '', false, true))");
Upvotes: 3