Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I tried to use solo.setDatePicker(int, int, int, int), but the code complains that the setDatePicker is not a valid function for solo. Does anyone know how to do this? Thanks!

like image 682
Char Avatar asked Feb 23 '23 11:02

Char


1 Answers

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. I simply click on the button that opens my DatePickerDialog, change the date and set it.

This also works for TimePickerDialog, just use .setTimePicker(0,10,0).

like image 60
Jean-Philippe Roy Avatar answered Mar 07 '23 08:03

Jean-Philippe Roy