2014-02-28 25 views
1

將calabash-android從0.4.18升級到0.4.20後,我的腳本中的set_text函數什麼也不做,我無法設置textfield的文本Usename和Password 。 這個腳本仍然可以用Calabash-android 0.4.18正常工作。在瀏覽庫源代碼後,我發現庫版本0.4.18和0.4.20之間的set_text函數存在差異。這裏有兩個片段的代碼:set_text函數在calabash-android中不執行任何操作0.4.20

C:\ Ruby193 \ lib中\紅寶石\寶石\ 1.9.1 \寶石\蠡-機器人-0.4.18 \ lib中\蠡-機器人\ operation.rb

def set_text(uiquery, txt) 
raise "Currently queries are only supported for webviews" unless uiquery.start_with? "webView" 

uiquery.slice!(0, "webView".length) 
if uiquery =~ /(css|xpath):\s*(.*)/ 
    r = performAction("set_text", $1, $2, txt) 
    JSON.parse(r["message"]) 
else 
raise "Invalid query #{uiquery}" 
end 
end 

C:\ Ruby193 \ LIB \紅寶石\寶石\ 1.9.1 \ \寶石葫蘆,Android的0.4.20 \ LIB \葫蘆,機器人\ operation.rb

def set_text(uiquery, txt) 
view,arguments = uiquery.split(" ",2) 
raise "Currently queries are only supported for webviews" unless view.downcase == "webview" 

if arguments =~ /(css|xpath):\s*(.*)/ 
    r = performAction("set_text", $1, $2, txt) 
else 
raise "Invalid query #{arguments}" 
end 
end 

有誰有同樣的問題?請幫助我。

謝謝。

回答

0

我想這應該雅

query("insert your query", setText: "insert text here") 

例如做的伎倆:

query("EditText id:'username'", setText:"[email protected]") 
query("EditText id:'password'", setText:"secret_password") 
相關問題