简体   繁体   English

Robotium - 如何使用Robotium在日期选择器中设置日期

[英]Robotium - How to set a date in date picker using Robotium

I have a date picker field where I want to set the dates (with a picker for Month, Day and Year with + and - for each field) but don't know how to do that in Robotium. 我有一个日期选择器字段,我想在其中设置日期(月份,日期和年份的选择器,+和 - 每个字段),但不知道如何在Robotium中执行此操作。 I tried to use solo.setDatePicker(int, int, int, int), but the code complains that the setDatePicker is not a valid function for solo. 我尝试使用solo.setDatePicker(int,int,int,int),但代码抱怨setDatePicker不是solo的有效函数。 Does anyone know how to do this? 有谁知道如何做到这一点? Thanks! 谢谢!

I found this question while searching how to do this myself, and I tried the method you've cited in your question and it worked like a charm. 我在自己搜索如何做的时候发现了这个问题,我尝试了你在问题中引用的方法,它就像一个魅力。

Here's my little code snippet: 这是我的小代码片段:

    solo.clickOnText("Pick Date");
    solo.setDatePicker(0, 2012, 2, 16);
    solo.clickOnText("Set");

I'm guessing they added support to this method after you've tried it, I'm currently using Robotium 3.1 and it works really well. 我猜他们在尝试之后添加了对这种方法的支持,我现在正在使用Robotium 3.1,它的效果非常好。 I simply click on the button that opens my DatePickerDialog, change the date and set it. 我只需单击打开DatePickerDialog的按钮,更改日期并进行设置。

This also works for TimePickerDialog, just use .setTimePicker(0,10,0) . 这也适用于TimePickerDialog,只需使用.setTimePicker(0,10,0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM