Anyone know a good way to deal with date picker objects?

Asked by Edward Hunter

I'm trying to automate some data entry on an html page which uses a calendar date picker. The picker won't allow any text entry into the resulting date field, otherwise I'd have no problems. Though I have taken captures of every day in the calendar month, and created arrays to loop through - no matter what I do, Sikuli doesn't want to match on every day and the process intermittently breaks at some point.

I've tried images of single numbers, multiple numbers using an offset to point to one in particular, etc.

Very frustrating - has anyone worked with automating date pickers using Sikuli? I'm getting desperate because so far, to automate the process I'm working on, Sikuli seems to be the only hope.

Thanks in advance for any assistance,

Edward Hunter

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

If image matching does not work precisely and constantly, the only chance is to calculate the click points from the geometry and the systematic of the little calender panes.

Using the date and time modules from python should give a chance to calculate the position of the day in the month.

Since I don't know the specific date picker, I cannot tell about the strategy to go to a specific month in a specific year.

Revision history for this message
Edward Hunter (erhunter) said :
#2

Can you advise how and which python modules might be used to do this? Getting the specific month & year is no problem, those appear in mini drop downs so i have those handled.. It it the days of the month that are so error prone and frankly making me a little nuts. Thanks for taking a look into this!

Revision history for this message
RaiMan (raimund-hocke) said :
#3

The basic features are given by the module datetime (http://docs.python.org/library/datetime.html):

import datetime
x = datetime.date(2010, 7, 27) # which is today and will be yesterday tomorrow ;-)
(year, weekNumber, dayInWeek) = x.isocalendar() # as one example method
print dayInWeek # gives 2 for Tuesday (usable as column number)

To get the row number you have to evaluate the diff between week number of the 1st in this month and the wanted date:

weekInMonth = weekNumber - datetime.date(2010, 7, 1).isocalendar()[1] + 1
print weekInMonth # gives 5

This should be sufficient to get around. The rest is pixel counting ;-)

Can you help with this problem?

Provide an answer of your own, or ask Edward Hunter for more information if necessary.

To post a message you must log in.