Issue
Basically, i want to fill a field on the paypal register form. Here's my code:
final String paypal_url = "https://www.paypal.com/welcome/signup/#/email_password";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fillField();
}
private void fillField() {
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(paypal_url);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.loadUrl("javascript:document.getElementById('paypalAccountData_firstName').value = 'test';");
}
});
}
And this is the result: it loads the page and then displays this:
I had already tried almost every solution on this site, without success (the field was not filled).
Solution
You need to wait the entire web page loads, including its content (id="paypalAccountData_firstName"
)
So you should change
view.loadUrl("javascript:document.getElementById('paypalAccountData_firstName').value = 'test';");
to
view.loadUrl( "javascript:window.onload= (function(){ document.getElementById('paypalAccountData_firstName').value = 'test';})();");
Answered By - Paul Chu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.