Re: Issue with date picker in robot framework

2,604 views
Skip to first unread message
Message has been deleted

Tatu Aalto

unread,
Aug 19, 2014, 4:24:26 AM8/19/14
to kapil....@gmail.com, robotframework-users

Ugh

Because one can use RF with many different libraries, could you specify what library you are using (version too) and other relevant information is plus too. Now you are basically saying: my Internet is broken.

-Tatu
Send from my mobile

On 19 Aug 2014 11:06, "KAPIL MEHTA" <kapil....@gmail.com> wrote:
Hi,

How can we select a date from the date Picker dynamically in robot framework  ??

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Amol

unread,
Aug 21, 2014, 8:44:56 AM8/21/14
to robotframe...@googlegroups.com, kapil....@gmail.com
Hello,

I too am facing issue to select date from datepicker using Robot Framework. Please help.


On Tuesday, August 19, 2014 1:54:26 PM UTC+5:30, Tatu Aalto wrote:

Ugh

Because one can use RF with many different libraries, could you specify what library you are using (version too) and other relevant information is plus too. Now you are basically saying: my Internet is broken.

-Tatu
Send from my mobile

On 19 Aug 2014 11:06, "KAPIL MEHTA" <kapil....@gmail.com> wrote:
Hi,

How can we select a date from the date Picker dynamically in robot framework  ??

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Kevin O.

unread,
Aug 21, 2014, 11:37:56 AM8/21/14
to robotframe...@googlegroups.com
It depends on the widget. Here is some hastily written code for handling a yui calendar widget. I'm not particularly proud of it, but it works. In how the widget is used in the AUT, some days are "available" and thus the day is a link - I think this was customization. Otherwise the day is not a link.
Note that no JavaScript or WebDriver/Selenium2Library internals are used.

Select Date From yui Calendar
    [Arguments]    ${date}    ${xpath}=//div[contains(@class,'yui-calcontainer')]    ${max months}=24
    [Documentation]    `date` must be in format MM/DD/YYYY (0-padded or not).
    ...
    ...    xpath should point to the div that has class yui-calcontainer. `max months` is the maximum amount of months the keyword will go forward or backword from the currently displayed month.
    ${month}    ${day}    ${year}    Evaluate    [int(n) for n in "${date}".split("/")]
    ${target}    Evaluate    datetime.datetime(${year}, ${month}, ${day})    datetime
    ${current month and year}    Get Text    xpath=${xpath}//div[@class='calheader']    # current here refers to state of calendar at start of keyword
    ${current month name}    ${current year}    Set Variable    ${current month and year.strip().split()}
    ${current month}    Evaluate    list(calendar.month_name).index('${current month name}')    calendar    # name -> index
    ${current}    Evaluate    datetime.datetime(${current year}, ${current month}, 1)    datetime
    ${diff}    Evaluate    (${current.__repr__()} - ${target.__repr__()}).days    datetime
    ${month name}    Evaluate    calendar.month_name[${month}]    calendar
    : FOR    ${i}    IN RANGE    ${max months}
    \    ${cal month and year}    Get Text    xpath=${xpath}//div[@class='calheader']
    \    ${cal month}    ${cal year}    Set Variable    ${cal month and year.strip().split()}
    \    Run Keyword If    '${cal month}'=='${month name}' and ${cal year}==${year}    Exit For Loop
    \    Run Keyword If    ${diff} > 0    Click Element    xpath=${xpath}//a[@class="calnavleft"]
    \    Run Keyword If    ${diff} < 0    Click Element    xpath=${xpath}//a[@class="calnavright"]
    ${available}    Get Matching Xpath Count    ${xpath}//a[.=${day.__repr__()}]
    Run Keyword If    ${available}    Click Element    xpath=${xpath}//a[.=${day.__repr__()}]
    Run Keyword Unless    ${available}    Log    Date ${date} not available for selection
    Run Keyword Unless    ${available}    Click Element    xpath=//*[@id='productDeliveryDateCalContainer']/a/span    #close the calendar
    [Return]    ${available} 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages