2011-11-20 3 views
0

나는 emualator에서 작동하는이 코드를 작성했습니다. 실제 장치에서 어떻게 작동합니까? 그냥 장치를 연결하고 APK의 위치 (장치 위치)를 변경하는 것입니까?실제 장치 monkeyrunner 스크립트에서 실행하는 방법은 무엇입니까?

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

# Connect to the current device 
device = MonkeyRunner.waitForConnection() 

# Install package 
device.installPackage('C:/android-sdk-windows/tools/lib/purchase.apk') 

# Run activity 
device.startActivity(component='com.mobilenetwork.purchase/.StartPage ') 

# Importing time 
import time 

# Waiting for 10 secs to be launched on the emulator: 
time.sleep(10) 
device.press('KEYCODE_BUTTON_SELECT','DOWN','') 

# Screenshot 
time.sleep(10) 
result = device.takeSnapshot() 

# Writes the screenshot to a file 
result.writeToFile('G:\\Screenshot\\screen_shot.png','png') 

답변

2

실제 장치에서 작동하는 것처럼 보입니다. 문제가 발생하는 경우 "MonkeyRunner.sleep (n)"(n은 숫자) 문장을 추가하는 것이 좋습니다. 일부 장치는 마지막 작업이 끝날 때까지 기다리지 않고 다음 작업을 요청합니다.

+0

죄송합니다 !!!!!! 게시하는 것을 잊어 버렸습니다 .. 기기를 연결하면 자동으로 작동합니다 .. 감사합니다. – ChanGan

0

장치에 연결하기 전에 패키지 및 활동을 구성 해보십시오.

관련 문제