2

I have an application with nested pages in it. I wrote a script for monkeyrunner . My script is able to start applications and access object of the page. Now when I perform touch to one of my buttons it load the next page. Now I am not able to perform touch event to the object (button2) of 2nd page.

  #! /usr/bin/env monkeyrunner

import sys
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
from com.android.monkeyrunner.easy import EasyMonkeyDevice
from com.android.monkeyrunner.easy import By

# connect to the device
device = MonkeyRunner.waitForConnection()
apk_path = device.shell('pm path com.test.myApp')
if apk_path.startswith('package:'):
    print "myapp already installed."
else:
    print "myapp not installed, installing APKs..."
device.installPackage('myApp.apk')
print "launching myapp..."
device.startActivity(component='com.test.myApp/com.test.myApp.main')
# use the EasyMonkey API
easyDevice = EasyMonkeyDevice(device)
MonkeyRunner.sleep(5)
easyDevice.touch(By.id('id/button1'),MonkeyDevice.DOWN_AND_UP)
#on click button 1 user enters in page2
#press button2 of page 2
easyDevice.touch(By.id('id/button2'),MonkeyDevice.DOWN_AND_UP)
print "end"

button1 click (touch) event done properly. But unable to perform button2 click (touch) event on page 2. Why ?

  • You should give [AndroidViewClient](https://github.com/dtmilano/AndroidViewClient) a shot, after touching `id/button1`, you'll be able to obtain hierarchy again using `vc.dump()` and then touch `id/button2` – Diego Torres Milano May 02 '13 at 02:32
  • Thanks for your reply, after adding AndroidClientView am facing problem with touch event."[com.android.chimpchat.adb.AdbChimpDevice] Error sending touch event: 522 391 UP" I replace "easyDevice.touch(By.id('id/button1'),MonkeyDevice.DOWN_AND_UP)" by devID = vc.findViewById("id/button1") devID.touch(). so now i can't even able to perform click on button1. – Tushar Kanani May 02 '13 at 06:14
  • Restarting adb sometimes helps. I think the problem is not AVC related. – Diego Torres Milano May 02 '13 at 15:06
  • I try this but not work. Still facing same issue – Tushar Kanani May 03 '13 at 06:39

0 Answers0