2

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
                    "})()");
             }  
         });
5
  • document.forms["form"].submit(); should work, have you checked that it (the javascript function) is happy in a standalone browser? Commented Mar 11, 2013 at 0:02
  • When I use document.forms["form"].submit(); the page just reloads. Maybe this will help <a id="loginButton" class="buttonbarbutton" name="loginButton" onclick="return confirmSubmit();" href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("loginButton", "", true, "", "", false, true))'>Login</a> Commented Mar 11, 2013 at 0:47
  • might make more sense if we can see the HTML as well. I don't have a tablet with me to test at the moment, but can have a look tomorrow if there's an HTML sample to complete the picture (not sure what I'm missing at the moment!) Commented Mar 11, 2013 at 4:06
  • 1
    I tried webview.loadUrl("javascript:confirmSubmit()"); and the "Login" button text changed to "Logging In..." but then nothing else happens. Any thoughts? Commented Mar 12, 2013 at 4:15
  • Offbeatmammal, Thank you for trying to help Commented Mar 12, 2013 at 4:30

1 Answer 1

3

I figured it out, the following worked for me:

webview.loadUrl("javascript:WebForm_DoPostBackWithOptions(
  new WebForm_PostBackOptions('loginButton', '', true, '', '', false, true))");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.