开发者

Auto click on WebView

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜