【问题标题】:Select Item of Spinner error in Robotium在 Robotium 中选择 Spinner 错误项
【发布时间】:2016-01-06 09:43:20
【问题描述】:

我制作了一个包含Spinner 的 UI 测试。当我执行时:

  solo.clickOnView(solo.getView(R.id.spinner_editwebsite));

微调器可以显示选项,但无法选择选项然后测试停止!

然后发生错误!

我尝试添加

`solo.pressSpinnerItem(0,1);` 

背后

`solo.clickOnView(solo.getView(R.id.spinner_editwebsite));`

但不行!

【问题讨论】:

    标签: android robotium android-testing ui-testing


    【解决方案1】:

    看看这个答案:

    似乎他们现在把这些课程都取消了。我自己也遇到了这个但是 找到了一种正确且通用的方法。

    // 0 is the first spinner in the layout
    View view1 = solo.getView(Spinner.class, 0);
    solo.clickOnView(view1);
    solo.scrollToTop(); // I put this in here so that it always keeps the list at start
    // select the 10th item in the spinner
    solo.clickOnView(solo.getView(TextView.class, 10));
    

    发件人:How do I click the first item in a spinner using Robotium?

    如您所见,您尝试使用的方法似乎已被弃用。 尝试使用上面的代码而不是您的代码。

    希望对你有帮助

    【讨论】:

    • 不行,只能显示项目,不能选择项目
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多