0

I'm trying to use the new evaluateJavascript method in Android 4.4, but when i try to evaluate this javascript code

browser.evaluateJavascript("(function() { document.getElementById('login').value='"+username+"'; document.getElementById('password').value='"+password+"'; document.getElementsByTagName('input')[2].click(); return '';})();",new ValueCallback<String>() {
    @Override public void onReceiveValue(String s) {

    } 
});

the app crashes returning:

Fatal signal 6 (SIGABRT) at 0x00006225 (code=-6), thread 25125

the javascript code is correct, because with the old way

browser.loadUrl("javascript:(function() { ...

it works.

doing some tests, i've found that the problem is when is executed the function

 document.getElementsByTagName('input')[2].click();

the input is a submit button, that sends a form.

how can i do to fill the form and send it?

1 Answers1

0

As per the Trigger form submission in chrome javascript console question it might be simpler to call submit() on the form. I have tried reproducing your problem but didn't get a crash - using both click() on the submit button and submit() on a form worked fine for me.

The SIGABRT looks quite bad though, are you calling the API from the UI thread? If no, then try that first. If it's called from the UI thread then you definitely should file a bug on the Android Open Source Project Issue Tracker. Ideally you'd include the the output of adb bugreport immediately after the crash and a sample app demonstrating the issue.

Community
  • 1
  • 1
marcin.kosiba
  • 3,221
  • 14
  • 19