# Imports the monkeyrunner modules used by this program from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,MonkeyImage # Connects to the current device, returning a MonkeyDevice object device = MonkeyRunner.waitForConnection(10,'LNBUMRLBAAWCYPDA') # Installs the Android package. Notice that this method returns a boolean, so you can test # to see if the installation worked. device.installPackage('D:/testapk/jingdong_13317.apk'# sets a variable with the package's internal name package = 'com.jingdong.app.mall' # sets a variable with the name of an Activity in the package activity = 'com.jingdong.app.mall.MainActivity' # sets the name of the component to start runComponent = package + '/' + activity #runComponent=activity # Runs the component device.startActivity(component=runComponent) # Presses the Menu button device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP) # Takes a screenshot result = device.takeSnapshot() # Writes the screenshot to a file result.writeToFile('D:\\testapk\\yy.png','png') |