0

EditTextとして表示されるテキストを含むアプリの検索バーにすぎないオブジェクトを取得する必要がありますが、でCurrent Location検索クエリを既に作成している場合、テキストは表示されず、検索バーは表示されます。myTextCurrent LocationmyText

Robotium Soloオブジェクトを使用してテスト ケースを作成しています。

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!

正しい方法を提案してください。

4

2 に答える 2

1

このコードで試してください:

if(!solo.searchText("Current Location"))
    assertTrue(solo.searchText("my Text"))
else
    assertTrue(solo.searchText("Current Location"));
于 2014-02-18T09:31:05.717 に答える
0
EditText view = (EditText) solo.getView(view1);

if(view == null){
    view = (EditText) solo.getView(view2)
}
view.getText().toString();
于 2014-02-18T07:09:15.960 に答える