1

txt.setErrorテキストがあり、テスト中にエラーが画面に表示されるかどうかを確認したいのですが、テストケースは次のとおりです。

solo.enterText(0, "example");
solo.clickOnImageButton(3);
assertTrue(solo.searchText("E-posta adresleri için lütfen şu biçimi kullanın: ad@example.com"));

ここに画像の説明を入力してください

画像ボタンをクリックすると、setErrorテキストが表示されます

しかし、AssertionFailedErrorが発生しました。何が間違っているのでしょうか。

編集:

問題の原因はRobotiumのリリースでした。2.1を使用していましたが、このアサーションにはrobotium3.0以上が必要です。

4

2 に答える 2

2

assertTrue(solo.searchText()) の代わりに、solo.waitfortext() を使用してみてください。問題はおそらく、テキストが表示される前にアサーションが実行されていることです。

したがって、ここには2つの可能なオプションがあると思います。

オプション1:

solo.enterText(0, "example");
solo.clickOnImageButton(3);
solo.waitforactivity(solo.getcurrentactivity().tostring). // you will wait untill the screen is entirely displayed.
assertTrue(solo.searchText("E-posta adresleri için lütfen şu biçimi kullanın: ad@example.com"));

オプション 2 (最適なオプション)

solo.enterText(0, "example");
solo.clickOnImageButton(3);
boolean textExist = solo.WaitForText("E-posta adresleri için lütfen şu biçimi kullanın: ad@example.com"));
if (!textExist){
Fail();
}
于 2013-05-16T16:08:42.103 に答える
0

Another option:

EditText myEditText = (android.widget.EditText) solo.getView(com.my.app.R.id.myEditText);
solo.clickOnView(myButton);

//Waits for error
solo.sleep(2000);

boolean result = myEditText.getError() == null;
if(!result){
    fail();
}
于 2015-03-30T21:45:32.027 に答える