[英]Robotium AssertionFailedError: Click can not be completed
I have been getting "Click can not be completed" error when running my tests but it happens intermittently. 运行测试时,出现“无法完成点击”错误,但它间歇性地发生。
Before calling clickOnView, I make sure that the view is not null. 在调用clickOnView之前,请确保该视图不为null。
Is there anything else that I need to check on before calling clickOnView? 在致电clickOnView之前,还有其他需要检查的内容吗?
Button btnLike = (Button) vwItem.findViewById(R.id.buttonLike);
assertTrue(solo.waitForCondition(new Common.WaitUntilViewNotNull(solo, vwItem, R.id.buttonLike), 5000));
solo.clickOnView(btnLike);
public static class WaitUntilViewNotNull implements Condition {
int viewId;
Solo solo;
View parentView;
public WaitUntilViewNotNull(Solo solo, View parentView, int viewId) {
this.solo = solo;
this.viewId = viewId;
this.parentView = parentView;
}
@Override
public boolean isSatisfied() {
View v = null;
if (parentView != null) {
v = (View)parentView.findViewById(viewId);
}
else {
v = (View) solo.getView(viewId);
}
return v != null;
}
}
It seems that problem is in assigning btnLike
variable before view is rendered. 看来问题在于在渲染视图之前分配btnLike
变量。 Therefore it equals null
. 因此,它等于null
。
BTW, probably you'd prefer waitForView
instead of custom Condition
. 顺便说一句,您可能更希望使用waitForView
而不是自定义Condition
。
assertTrue(solo.waitForView(R.id.buttonLike, 1, 5000));
Button btnLike = (Button) vwItem.findViewById(R.id.buttonLike);
solo.clickOnView(btnLike);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.