-3

How we write in Descriptive programming for Calendar function by clicking it will form fill

1 Answers1

-1

Hi here I have mentioned my code which takes inpud date in dd/mm/yyyy format and field name is the partial string of the html id of the div in which the date-picker icon is placed. this is because in my application that was the only part which was changing.

Hope it'll help.

Function selectDateFromDatePicker(strInputDate,strFieldName)
   If Ucase(strInputDate) <> "BLANK" Then
        arrayDate = split(strInputDate,"/")
    '   print "Month : " & arrayDate(0) & " Day : " & arrayDate(1) & " Year : " & arrayDate(2)
        Set oPage= Browser("name:=CitiDirect BE \(SM\)").Page("title:=CitiDirect BE \(SM\)")
        'oPage.WebElement("html id:=manageFilter:dateCreatedFrmPopup").HighLight
        set objCalSpan = oPage_RVAM.WebElement("html id:=" & strFieldName & "Popup")
        objCalSpan.Image("html id:=" & strFieldName & "PopupButton").Click
        set objCalTable = oPage.WebTable("html id:=" & strFieldName & "")
        arrayVar = Split(FormatDateTime(now(),1)," ")
        objCalTable.WebElement("class:=rich-calendar-tool-btn","innertext:=" & arrayVar(1)& ", " & arrayVar(3)).Click
'       oPage.WebTable("html id:=" & strFieldName & "DateEditorLayout").HighLight
        Set dateEditorLayout = oPage.WebTable("html id:=" & strFieldName & "DateEditorLayout")
        'select month
        strMonth = MonthName(arrayDate(0))
    '   print "strMonth" & strMonth
        dateEditorLayout.WebElement("class:=rich-calendar-editor-btn","innertext:=" & Mid(strMonth,1,3)).Click
        flgYrFound = False
        Do
            strStartYear = oPage.WebElement("html id:=" & strFieldName & "DateEditorLayoutY0").GetROProperty("innertext")
            strEndYear = oPage.WebElement("html id:=" & strFieldName & "DateEditorLayoutY9").GetROProperty("innertext")
            If arrayDate(2) < strStartYear   Then
                dateEditorLayout.WebElement("class:=rich-calendar-editor-btn","innertext:=<").Click
                ElseIf arrayDate(2) > strEndYear Then
                dateEditorLayout.WebElement("class:=rich-calendar-editor-btn","innertext:=>").Click
                Else
                flgYrFound = True
            End If
        Loop While(flgYrFound = False)
        If flgYrFound Then
            'select year
            dateEditorLayout.WebElement("class:=rich-calendar-editor-btn.*","innertext:=" & arrayDate(2)).Click
        End If
        'click OK
        dateEditorLayout.WebElement("html id:=" & strFieldName & "DateEditorButtonOk").Click
        'select day
        objCalTable.WebElement("html id:=" & strFieldName & "DayCell.*","innertext:=" & Cstr(Cint(arrayDate(1))),"class:=.*DayCell rich-calendar-cell rich-calendar-btn").Click
   End If
End Function
Frosty
  • 299
  • 5
  • 31