2016-10-27 11 views
5

Android uygulamamı test etmek için sonsuz döngü yapmak için basit bir python betiği oluşturdum, ancak yalnızca bir kez başarılı bir şekilde çalışıyor ve duruyor.Gerçek python betiği sonsuz döngü olsa da, ancak sadece bir kez yürütülürken - 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('66b6cc0e') 

while True: 
    device.touch (300, 1750, 'DOWN_AND_UP') 
    MonkeyRunner.sleep(3) 
    device.touch(742, 1213, 'DOWN_AND_UP') 
    MonkeyRunner.sleep(10) 
    device.touch(554, 1613, 'DOWN_AND_UP') 
    MonkeyRunner.sleep(10) 

# Push SEND MESSAGE 
device.touch(300, 1750, 'DOWN_AND_UP') 
MonkeyRunner.sleep(3) 
device.touch(742, 1213, 'DOWN_AND_UP') 
MonkeyRunner.sleep(10) 
device.touch(554, 1613, 'DOWN_AND_UP') 
MonkeyRunner.sleep(10) 
+0

Bir sonraki yinelemede 'uyuma '' dokunma 'işlemi zaman aşımına uğradı mı? – nullpointer

+0

Ayrıca, içe aktarma zamanı time.sleep (10) ' – nullpointer

+0

kullanmayı deneyin. Döngüdeki bir istisna, yakalanmadığında döngüden çıkar. – zvone

cevap

0

AndroidViewClient/culebra ürününü kullanıyorum, bu ürün monkeyruner yerine hemen kullanmaktadır ancak python'dur.

Ben de

#! /usr/bin/env python 

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

import re 
import sys 
import os 

from com.dtmilano.android.viewclient import ViewClient 


# Connects to the current device, returning a MonkeyDevice object 
#device = MonkeyRunner.waitForConnection('66b6cc0e') 

kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False} 
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1) 


while True: 
    print "loop" 
    device.touch (300, 1750, 'DOWN_AND_UP') 
    ViewClient.sleep(3) 
    device.touch(742, 1213, 'DOWN_AND_UP') 
    ViewClient.sleep(10) 
    device.touch(554, 1613, 'DOWN_AND_UP') 
    ViewClient.sleep(10) 

# Push SEND MESSAGE 
device.touch(300, 1750, 'DOWN_AND_UP') 
ViewClient.sleep(3) 
device.touch(742, 1213, 'DOWN_AND_UP') 
ViewClient.sleep(10) 
device.touch(554, 1613, 'DOWN_AND_UP') 
ViewClient.sleep(10) 

, sadece UI üzerindeki nokta ve tıklayarak Culebra GUI yararlanmak ve otomatik komut (hatta unittests) bu tür üretebilir olduğunu göstermek için komut dosyasına değişiklikler yaptı.