← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #240489]: trying to automate selecting date on a calendar on a webpage

 

Question #240489 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/240489

RaiMan proposed the following answer:
Eugene's suggestion is ok for now. Version 1.1  will have a repeat
shortcut.

For dropdown menues, you always should check, wether it accepts entering the text directly and positions at the respective entry.
So for the year drop down check this after having clicked open the menu:
type("2013")
type(Key.ENTER)

same goes for the month menu
type("June")
type(Key.ENTER)

The date/datetime modules have appropriate functions, to evaluate these
items directly from your raw date.

As for the selection of the day: the day area is a regular square having 5 rows each 7 columns. So you once evaluate the geometrics of this area and then you can evaluate each click point easily:
# the area on your image is 228x118
# you somehow have to evaluate this are starting form a found visual (e.g. the header containing the day names)
days = Region(<to be evaluated>)
dw = 118/5
dh = 228/5
dayOne = days.topLeft().offset(dw/2, dh/2)

# e.g. day 18
day = 18
dx = day % 7
dy = day // 7

this works, where the 1st is a sunday.

In other cases you have to evaluate the offset using the date functions
and add it:

day = 18 + offset (0 for Sunday and 6 for Saturday)
dx = day % 7
dy = day // 7

then simply:
click(dayOne.offset((dx-1)*dw, (dy-1)*dh)

an example for another calendar:
https://dl.dropboxusercontent.com/u/42895525/ddcalendar.sikuli.zip

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.