我必須得到一個EditText
對象,它不過是一個搜索欄,在應用與文本可見的Current Location
,但是如果我已經做了一個搜索查詢與myText
條件語句,沒有Current Location
文字可見,並且搜索欄顯示myText
。用於獲取的TextView
我正在使用Robotium獨奏對象編寫測試用例。
我該如何寫條件語句來獲得EditText
,儘管它顯示的是什麼文本。像
if !found solo.getText("Current Location")
search solo.getText("myText");
東西這是我在做什麼目前
EditText text = (EditText) solo.getText("Current Location");
if(text == null){
text = (EditText) solo.getText("myText");
//my rest of the code goes here....
但是,這將引發異常,如果Current Location
沒有出現在搜索欄中。
junit.framework.AssertionFailedError: TextView with text: 'Current Location' is not found!
請建議正確的方法。
什麼是'solo'對象? – Merlevede
其Robotium。 android自動化工具。 –