I want to check if view is visible, so I used isShown() method on view, but it's quite useless because I create my own views and these depends on id, so here's example view:
private static final String BTN_ADD_CURRENCY_ALERT = "action_add_currency_alert";
private View btn_AddAlert() {
return mainHelper.getView(BTN_ADD_CURRENCY_ALERT);
}
Here is body of getView();
public View getView(String id) {
return solo.getView(id);
}
Then I want to see if this element is visible (if not then should return false).
I call this like this
if (btn_addAlert().isShown()){...}
And the problem is that when I call btn_addAlert()
and view is not visible I get AssertionFailedError and it's not even going to isShown().
I catched exception
private boolean catcher() {
try {
btn_addAlert().isShown();
return true;
} catch (AssertionFailedError e) {
return false;
}
}
but it's wrong way because exceptions are not for this and also I have to wait whole timeout time to make it throw exception. Then it just return false.
So what can I do in this situation?
Thanks is advance.