Android平台自动测试之Monkey测试工具(11)

发表于:2016-09-12来源:cnblogs作者:cnb_yangwei点击数: 标签:
1 # Imports the monkeyrunner modules used by this program 2 3 from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage 4 5 # Connects to the current device, returning a MonkeyDevic
复制代码
复制代码
1 # Imports the monkeyrunner modules used by this program
2  
3  from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage

5 # Connects to the current device, returning a MonkeyDevice object

7 device = MonkeyRunner.waitForConnection()

9 # Takes a screenshot
10 
11 result = device.takeSnapshot()
12 
13 # Writes the screenshot to a file
14 
15 result.writeToFile('./shotbegin.png','png')
16 
17 # Presses the Down button
18 
19 device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
20 
21 device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
22 

原文转自:http://www.cnblogs.com/iloverain/p/5604172.html