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 ?