Monkey runner

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')"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值