monkeyrunner的使用# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

Connects to the current device, returning a MonkeyDevice object

device = MonkeyRunner.waitForConnection()

Installs the Android package. Notice that this method returns a boolean, so you can test

to see if the installation worked.

device.installPackage(’/sdcard/qq.apk’)

sets a variable with the package’s internal name

package = ‘com.tencent.mobileqq’

sets a variable with the name of an Activity in the package

activity = ‘com.tencent.mobileqq.activity.SplashActivity’

sets the name of the component to start

runComponent = package + ‘/’ + activity

Runs the component

device.startActivity(component=runComponent)

Presses the Menu button

MonkeyRunner.sleep(2)
device.press(‘KEYCODE_MENU’, MonkeyDevice.DOWN_AND_UP)

Takes a screenshot

MonkeyRunner.sleep(2)
result = device.takeSnapshot()

Writes the screenshot to a file

MonkeyRunner.sleep(2)
result.writeToFile(‘c:\shot1.png’,‘png’)

相关文章:

  • 2021-10-06
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2021-06-11
  • 2022-12-23
  • 2021-07-04
猜你喜欢
  • 2022-12-23
  • 2022-01-19
  • 2021-12-30
  • 2021-12-03
  • 2021-09-30
  • 2022-02-14
  • 2021-09-13
相关资源
相似解决方案