开发者

Auto click on WebView

开发者 https://www.devze.com 2023-03-22 11:09 出处:网络
How can I perform click on WebView from java code? Is it possible to click on a s开发者_C百科pecified location (x,y)?

How can I perform click on WebView from java code? Is it possible to click on a s开发者_C百科pecified location (x,y)?

WebView.performClick()

doesn't work!


You can do this by injecting javascript to your webview using loadUrl():

mWebView.loadUrl("javascript:<your javascript here>");

This example code will perform a click on the element with id 'button_submit':

mWebView = new WebView(context);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("javascript:getElementById('button_submit').click();");
0

精彩评论

暂无评论...
验证码 换一张
取 消