For running tests on an Android app, how can I automate the tap on a x,y coordinate of either the view or the screen?
I am hoping that there is some call in ActivityInstrumentationTestCase2 or TouchUtils, but haven’t found one yet.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So, this I haven’t tried, but giving a look through the documentation, you might be able to do something to this effect:
Capture an
ACTION_DOWNMotionEvent(through the debugger from a touch action) and note its properties (down time, event time, and the meta state). This would only need to be done once to figure out what sort of values you should use to simulate a typical touch event.In your test program, create a new
MotionEventwithMotionEvent.obtain()MotionEvent newTouch = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN,x, y, metaState);
Dispatch the event on your view:
view.dispatchTouchEvent(newTouch);