1

我正在使用 Robotium Solo 4.0 为 Android 应用程序编写一些功能测试。以下序列给我带来了问题。我在 Nexus 4 上运行。

View cartIcon = solo.getView(R.id.cartBtn);
solo.clickOnView(cartIcon);

//Animation happens in app here for about 5 seconds before the email/password boxes are visible

solo.typeText((EditText)solo.getView(R.id.emailEdit), LOGIN_EMAIL);
solo.typeText((EditText)solo.getView(R.id.passwordEdit), LOGIN_PASSWORD);


//Execution pauses here for 30 seconds or so, then picks up at normal speed where it left off.
solo.clickOnView((Button)solo.getView(R.id.loginBtn), true);

正如您在上面的评论中看到的,在登录屏幕上填写登录电子邮件和密码后,测试执行暂停了很长时间,直到最后单击登录按钮并继续正常执行。有人对此有解决方案吗?

更新

需要注意的一点是,在单击 cartIcon 后,在 emailEdit 和 passwordEdit EditText 视图可用之前,有一个动画需要大约 5 秒才能完成下一个活动。我想知道 Robotium 是否试图过早地输入这些字段并失败,然后在继续之前等待超时。

在输入电子邮件和密码之前,我尝试做一个 solo.waitForText("Login") ,但这没有帮助。还有其他想法吗?

解决方案

糟糕——我是个白痴。R.id.emailEdit 和 R.id.passwordEdit 是错误的元素,并且不在此页面上。我调试并注意到两者都是空的,这显然导致 Robotium 在继续之前等待超时。在我交换了正确的元素 ID 后,一切都按预期工作。

如果 Robotium 在尝试与空视图交互时抛出异常,那就太好了。

4

0 回答 0