2012-01-20 37 views
2

考慮這種情況:驗證使用猴子亞軍

  1. 你有,你必須寫一些文字「ABCD」
  2. 接下來,您必須驗證,如果輸入的文本是否屬於正確的字符集的文本框(如UTF - 8),或者乾脆你必須驗證「ABCD」已進入文本框中

這是要替我在interview.I不得不編寫一個腳本monkeyrunner,可以做以上提到兩個操作。第一個是該死的容易。對第二個人有任何意見?

回答

2

使用AndroidViewClient這個monkeyrunner腳本可以像簡單的

#! /usr/bin/env monkeyrunner 

from com.dtmilano.android.viewclient import ViewClient 
... 

device = MonkeyRunner.waitForConnection() 
s = "abcd" 
device.type(s) 
vc = ViewClient(device) 
vc.dump() 
editText = vc.findViewById("id/EditText") # if you don't know the id you can use vc.getViewIds() 
if s == editText.mText(): 
    print "OK"