我有一个带嵌套页面的应用程序。 我为monkeyrunner写了一个脚本。我的脚本能够启动应用程序并访问页面的对象。现在当我对我的一个按钮执行触摸时,它会加载下一页。现在我无法对第二页的对象(按钮2)执行触摸事件。
#! /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"
按钮1单击(触摸)事件正确完成。但是无法在第2页上执行button2点击(触摸)事件。为什么?