2013-05-13 93 views
0

我在設備上使用Jelly Bean 4.2.2並嘗試使用Monkeyrunner腳本撥打電話。 我正在使用下面的代碼在ICS上工作得很好,但是在JB中,一旦打開了鍵盤撥號器屏幕,它就不會在編輯文本框中鍵入電話號碼。有沒有人遇到過這個問題?Android JB 4.2.2和Monkeyrunner腳本撥打電話

device.startActivity(component='com.android.contacts/com.android.contacts.activities.DialtactsActivity') 

device.type("8888888888") 

BR 作者Srini

+0

以下在JB上工作,所以我不會卡住atleast。現在上古爲什麼上述命令在JB上不起作用。 – user2344495 2013-05-13 05:58:31

+0

device.startActivity(action ='android.intent.action.CALL',data ='tel:8888888888') – user2344495 2013-05-13 05:59:25

回答

0

意圖的替代是正確的許多情況下,但是如果你真的想模擬真實用戶撥打一個號碼,您可以使用此culebra腳本自動生成略加編輯添加dialNumber方法和其他次要的東西:

#! /usr/local/bin/shebang monkeyrunner -plugin $AVC_HOME/bin/androidviewclient-$AVC_VERSION.jar @! 
# -*- coding: utf-8 -*- 
''' 
Copyright (C) 2013 Diego Torres Milano 
Created on 2013-05-15 by Culebra v0.9.8 

         __ __ __ __ 
        /\/\/\/\ 
____________________/ __\/ __\/ __\/ __\_____________________________ 
___________________/ /__/ /__/ /__/ /________________________________ 
        |/\ /\ /\ /\ \___ 
        |/ \_/ \_/ \_/ \ o \ 
              \_____/--< 
@author: Diego Torres Milano 
@author: Jennifer E. Swofford (ascii art snake) 
''' 


import re 
import sys 
import os 


from com.dtmilano.android.viewclient import ViewClient 

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice 

def dialNumber(number): 
    print "dialing", number 
    digits = [zero, one, two, three, four, five, six, seven, eight, nine] 
    for d in number: 
     if d in ['-', ' ']: 
      continue 
     digits[int(d)].touch() 
     vc.sleep(0.5) 
    dial.touch() 

device, serialno = ViewClient.connectToDeviceOrExit() 
device.startActivity(component='com.android.contacts/com.android.contacts.activities.DialtactsActivity') 
vc = ViewClient(device, serialno, autodump=False) 
vc.dump(window='-1') 

back = vc.findViewWithContentDescriptionOrRaise('backspace') 
one = vc.findViewWithContentDescriptionOrRaise('one') 
two = vc.findViewWithContentDescriptionOrRaise('two') 
three = vc.findViewWithContentDescriptionOrRaise('three') 
four = vc.findViewWithContentDescriptionOrRaise('four') 
five = vc.findViewWithContentDescriptionOrRaise('five') 
six = vc.findViewWithContentDescriptionOrRaise('six') 
seven = vc.findViewWithContentDescriptionOrRaise('seven') 
eight = vc.findViewWithContentDescriptionOrRaise('eight') 
nine = vc.findViewWithContentDescriptionOrRaise('nine') 
star = vc.findViewWithContentDescriptionOrRaise('star') 
zero = vc.findViewWithContentDescriptionOrRaise('zero') 
pound = vc.findViewWithContentDescriptionOrRaise('pound') 
dial = vc.findViewWithContentDescriptionOrRaise('dial') 
search = vc.findViewWithContentDescriptionOrRaise('search') 
moreOptions = vc.findViewWithContentDescriptionOrRaise('More options') 


dialNumber("800-555-1234")