Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monkeyrunner doesn't touch webview

I need to test android app which includes WebView with buttons.

Monkeyrunner works fine for all parts of the app except WebView. Button in WebView just ignores touches from Monkeyrunner. I see that button is clicked because it became grey but then button does nothing. If I use mouse on emulator or finger on real device then button works great.

I see from logcat that touch event was sent to the app but there is no action from the app.

Some code:

final WebView w = (WebView) findViewById(R.id.webView1);
String summary = "<html><body><b>Google</b><form action=http://google.com><input type=submit><input type=text></form></body></html>";
w.loadData(summary, "text/html", null);

Layout:

 <Button android:id="@+id/button1" android:text="Click me!" />
 <WebView android:id="@+id/webView1" />

Monkeyrunner py:

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection(10)
# android.widget.Button COORDINATES - THIS WORKS FINE
device.touch(10,100, 'DOWN_AND_UP')
# WEBVIEW BUTTON COORDINATES - BUTTON DOESN'T WORK
device.touch(200,200, 'DOWN_AND_UP')

I had tried separately DOWN delay UP - the same result. Monkeyrunner from Python or from inside Java do not work too. Flavors and wrappers for monkeyrunner like ChimpChat do not work.

I think it should work because there are so many web/HTML5 apps and it couldn't be true that all of them are not tested. But it appears opposite. Any ideas or suggestions how to enforce touch event for WebView components?

like image 606
Alex Avatar asked Feb 09 '13 02:02

Alex


1 Answers

This was a bug which I had reported to Android team. Some people had confirmed it. However with time it was merged with another bug and later that another bug was closed as "works as designed". Fortunately after few next Android versions it started to work as it supposed to do.

like image 138
Alex Avatar answered Oct 19 '22 01:10

Alex