Robotium:搜索文本
我遇到了一个奇怪的情况,我无法解释自己。
以下代码运行良好:
<代码> 独奏.睡眠(1000);
assertTrue(solo.searchText("银行业务"));
但以下代码失败:
<代码> assertTrue(solo.waitForText("银行业务", 1, 1000));
有人可以解释一下吗?
亲切的问候,
阿尔班.
I have a strange situation I can't explain myself.
The following code works well:
solo.sleep(1000);
assertTrue(solo.searchText("Banking"));
but the following code fails:
assertTrue(solo.waitForText("Banking", 1, 1000));
Can someone can explain me this?
Kind regards,
Alban.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是 waitForText 中的“1000”没有设置延迟,而是设置继续查找的时间。如果在该时间内没有找到文本,则返回 false。 查看 Robotium 源代码
尝试像这样的第二个版本,看看它是否不起作用:
此外,第一个版本之前的延迟可能不会改变任何东西。我认为第一个例子如果只是:
The problem is that '1000' in waitForText isn't setting a delay, it's setting how long to keep looking. If it doesn't find the text within that time, it returns false. See Robotium source
Try the second version like this and see if it doesn't work:
Also, the delay before the first one probably doesn't change anything. I think the first example would work just as well if it was only:
在 robotsium-1.7.1 之前,searchText() 存在一些问题。即使应该找到文本,它也绝对不总是能找到。您可能想使用简单的代码重试而不计时。
Before robotium-1.7.1 there were some issues with searchText(). It was definetely not always finding the text even when it should. You might want to try again with simple code without timing.