Good day, you need to automatically click on the button when the page is WebView in WebView . I do this, but from WebView the button is clicked, but not programmatically. What can be done in this situation? Thank.

 public class RostelecomLoginActivity extends Activity { WebView webView; String url; @SupressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_rostelecom_login); Intent webIntent = getIntent(); final String url = webIntent.getStringExtra("url"); webView = (WebView) findViewById(R.id.webView1); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSavePassword(true); webSettings.setSaveFormData(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webView.setWebViewClient(new WebViewClient() { public void onPageLoad(WebView view, String url) { } public void onPageStarted() { } public void onPageFinished(WebView view, String url) { webView.loadUrl("javascript:document.getElementById('mA').click()"); } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } }); webView.loadUrl(url); } } 
  • Try to just insert the javascript code at the end of the downloaded file and wrap it in window.onload. - Daniyar Supiev
  • one
    At the entrance to the mail your code button squeezes webView.loadUrl (" accounts.google.com" ); webView.loadUrl ("javascript: document.getElementById ('signIn'). click ()"); So you need to deal with the page - woesss

1 answer 1

It is not visible that webSettings are applied to the webView. I would try after all

 webView.getSettings().setJavaScriptEnabled(true); 
  • That here it is just there. Take a closer look. > WebSettings webSettings = webView.getSettings (); webSettings.setJavaScriptEnabled (true); Apparently the problem is different. - V.March