Date Picker on IOS

I have a test case that wants me to click on a date field and change the month to one month from now and the day to the 10th.

When I click on the Date field I get the IOS date picker showing today date.

Any suggestions?

Thanks

I swear I posted a lengthy response to this post yesterday with code and everything. Did you see it?

Nope. You may have lost your work?

With the fixed screen size of the iPhone, you can get away with using some fixed coordinates. I’m also assuming that the date picker that you’re scripting against has 3 columns for the month, day, and year. So in the code below, I first determine the name of the next month and then I move 1 month at a time until the OCR reads that month name:

put item the month mod 12 plus 1 of the monthnames into monthToSet
set the mousedragspeed to 1
repeat while readText((27, 354, 165, 391), contrast:yes, contrastColor:(181,188,211)) does not contain monthToSet
	put readText((27, 354, 165, 391), contrast:yes, contrastColor:(181,188,211))
	drag(97, 373)
	drop(97, 330)
	wait 1
end repeat

To set the day to the 10th, you can be a little more direct and not really worry about what is displayed if you know that it will always come up with todays date:

put the day - 10 into daysOff
put daysOff
set the mousedragspeed to 1
if daysOff is a negative number then
	repeat daysOff times
		drag (196, 372)
		drop(196, 327)
		wait 1
	end repeat
else
	repeat daysOff times
		drag (196, 372)
		drop(196, 415)
		wait 1
	end repeat
end if

Actually, if you know it’s always going to come up with today’s date, then all you’d really have to do for the month is this part:

set the mouseDragSpeed to 1
drag(97, 373)
drop(97, 330)

Since you know it’s coming up with the current month, you can just nudge it once to get the next month. Changing the year as necessary is left as an exercise for the reader (but let us know if you need help with that.)

I have done data pick on iPhone.

Here is the trick to pick data:
For iPhone data picker, if you click on the position right below the current data, it will move one step up. Because the position on iPhone is fixed.
For month, you can click once to step to the next month. For example, Click (166, 830).

For date, you can firstly scroll to the first day of the month.
Then, click 9 times.

    repeat with m = 1 to 9
wait 1.0
click (466, 830)
end repeat	

The following code is what I use for Data picker.
It’s different than yours. But can be a very good reference.


//Scroll back to the top position
DragAndDrop “iosSearchMinVarStartPoint”, “iosSearchMinVarEndPoint”
DragAndDrop “iosSearchMinVarStartPoint”, “iosSearchMinVarEndPoint”
DragAndDrop “iosSearchMinVarStartPoint”, “iosSearchMinVarEndPoint”
DragAndDrop “iosSearchMaxVarStartPoint”, “iosSearchMaxVarEndPoint”
DragAndDrop “iosSearchMaxVarStartPoint”, “iosSearchMaxVarEndPoint”
DragAndDrop “iosSearchMaxVarStartPoint”, “iosSearchMaxVarEndPoint”
DragAndDrop “iosSearchMaxVarStartPoint”, “iosSearchMaxVarEndPoint”

Wait 8.0

put 28 into MinVar
put 40 into MaxVar

    //Get how many times to step up for minVar
    put MinVar-18 into minDiff

repeat with n = 1 to minDiff
	wait 1.0
	Click (166, 830)
end repeat	

   //Get how many times to step up for maxVar
put MaxVar-MinVar into maxDiff

repeat with m = 1 to maxDiff
	wait 1.0
	click (466, 830)
end repeat