from com.android.monkeyrunner importMonkeyRunner,MonkeyDevice
from com.android.monkeyrunner.easy import EasyMonkeyDevice
from com.android.monkeyrunner.easy import By
device=MonkeyRunner.waitForConnection()
device.installPackage('./xxxTriton-debug.apk')
print 'Install successful'
device.startActivity(component='com.xxx.android.tms/.diagnostics.Diagnostics')
MonkeyRunner.sleep(3.0)
device.type('endpeng1@xxx.com')
MonkeyRunner.sleep(2.0)
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.type('Wsws1234')
MonkeyRunner.sleep(3.0)
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.type('https://mcb-cn-mobile-end.odd.blackspider.com')
MonkeyRunner.sleep(3.0)
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.type('https://mcb-cn-mobile-end.odd.blackspider.com')
MonkeyRunner.sleep(3.0)
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.type('https://mcb-cn-mobile-end.odd.blackspider.com')
MonkeyRunner.sleep(3.0)
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.type('https://mcb-cn-mobile-end.odd.blackspider.com')
MonkeyRunner.sleep(3.0)
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.press('KEYCODE_ENTER',MonkeyDevice.DOWN_AND_UP)
print 'Please wait for 220s'
MonkeyRunner.sleep(220.0)
device.press('KEYCODE_ENTER',MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(3.0)
device.press('KEYCODE_ENTER',MonkeyDevice.DOWN_AND_UP)
try:
easy_device = EasyMonkeyDevice(device)
except:
pass
MonkeyRunner.sleep(3.0)
easy_device.touch(By.id('id/action_button'),MonkeyDevice.DOWN_AND_UP)
print 'Please wait for 80s'
MonkeyRunner.sleep(80.0)
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.press('KEYCODE_DPAD_DOWN','DOWN_AND_UP')
device.press('KEYCODE_ENTER',MonkeyDevice.DOWN_AND_UP)
1.Please according this site to install android simulator
http://www.cr173.com/html/15072_1.html
2.Install windows python environment
3.Move “WebsenseTriton-debug.apk” to directory“platform-tools”
4.Move “monkeyrunner.py” to directory “tools“
5. use cmd to access directory “tools”, and launchcommand ” monkeyrunner monkeyrunner.py”
---------
Hi team,
After some investigation, I can remote control the androiddevice and emulator using adb, monkey, and monkeyrunner. Here are refined stepsof how to connect
to them, install/uninstall application, ,take snapshot, andetc. You could do more research by yourself.
1. Use adb to see the device list
D:\adt-bundle-windows-x86-20130219\sdk\platform-tools>adb.exedevices
List of devices attached
4107e08c0865bfcb device
2. Start monkenrunner
D:\adt-bundle-windows-x86-20130219\sdk\tools\monkeyrunner
3. Connect to the device
>>from com.android.monkeyrunner importMonkeyRunner,MonkeyDevice
>>device=MonkeyRunner.waitForConnection(5,'4107e08c0865bfcb')
4. Send comments to device/emulator
Press HOME button: >>device.press('KEYCODE_HOME','DOWN_AND_UP')
Press POWER button: >>device.press('KEYCODE_POWER','DOWN_AND_UP')
5. Install and uninstall application
>> device.installPackage('myproject/bin/test.apk')
>> device.removePackage('com.dataviz.docstogo')
6. Take snapshot
>>result = device.takeSnapshot()
>>result.writeToFile('shot1.png','png')
7. Launch application
>>device.startActivity('com.android.browser/.BrowserActivity')
Looking forward to your updates.
(8)Launche application
device.touch(200,1000,"DOWN_AND_UP")
(200,1000) is the coordinates of the applications.
(9)input text
device.type('endyong1@xxx.com')
(10)Enter
device.press('KEYCODE_ENTER',MonkeyDevice.DOWN_AND_UP)
Please try this
11. "device.startActivity(component='com.xxx.android.tms/.diagnostics.Diagnostics')"