'<<< funtion will select the date from date picker based on the input data.>>>
'**********************************************************************************************************
'Function Name: Fun_DatePicker(ip_Obj, ip_InputDate)
'Description : Select the Date from the Date Picker on the Screen as per the User Input Date.
'Author: Naresh Gupta. D
'Parameters: Input date, Calendar Object
'Return value 1 for fail
'Example: Call Fun_DatePicker(objCalendar, Parameter("p_AR_RS_NightOfDate"))
'<<<Decleration of Object for Calendar>>>
'Dim objCalendar
'Set objCalendar = Browser("Browser Main").Page("Run Model").Image("Calendar")
'**********************************************************************************************************
Function Fun_DatePicker(ip_Obj, ip_InputDate)
Dim arrDateDetailsCollection, intDay, intMonth, intYear, intYearFromCalendar, intDifOfYears, intMaxWaitCount
Fun_DatePicker = "0"
arrDateDetailsCollection=Split(ip_InputDate, "/")
'<<<Verifying the Month field is numeric or not>>>
If (Not IsNumeric(arrDateDetailsCollection(0))) Then
Fun_ReportFailure "Verify the input passed for Month", "Invalid input passed for Month field and that is : " &arrDateDetailsCollection(0), Nothing
Fun_DatePicker = "1"
ExitFunction
'<<<Verifying the Month field is less than Zero or Empty or Greater than 12>>>
ElseIf arrDateDetailsCollection(0) <= 0 Or arrDateDetailsCollection(0) = "" Or arrDateDetailsCollection(0) > 12 Then
Fun_ReportFailure "Verify the input passed for Month", "Invalid input passed for Month field and that is : " &arrDateDetailsCollection(0), Nothing
Fun_DatePicker = "1"
ExitFunction
End If
'<<<Verifying the Month field is numeric or not>>>
If (Not IsNumeric(arrDateDetailsCollection(1))) Then
Fun_ReportFailure "Verify the input passed for Date", "Invalid input passed for the Date field that is : " &arrDateDetailsCollection(1), Nothing
Fun_DatePicker = "1"
ExitFunction
'<<<Verifying the Month field is less than Zero or Empty or Greater than 31>>>
ElseIf arrDateDetailsCollection(1) <= 0 Or arrDateDetailsCollection(1) = "" Or arrDateDetailsCollection(1) > 31 Then
Fun_ReportFailure "Verify the input passed for Date", "Invalid input passed for the Date field that is : " &arrDateDetailsCollection(1), Nothing
Fun_DatePicker = "1"
ExitFunction
End If
'<<<Verifying the Month field is numeric or not>>>
If (Not IsNumeric(arrDateDetailsCollection(2))) Then
Fun_ReportFailure "Verify the input passed for Year", "Invalid input passed for the Year filed that is : " &arrDateDetailsCollection(2), Nothing
Fun_DatePicker = "1"
ExitFunction
'<<<Verifying the Month field is less than Zero or Empty>>>
ElseIf arrDateDetailsCollection(2) <= 0 Or arrDateDetailsCollection(2) = "" Then
Fun_ReportFailure "Verify the input passed for Year", "Invalid input passed for the Year filed that is : " &arrDateDetailsCollection(2), Nothing
Fun_DatePicker = "1"
ExitFunction
End If
intMonth=cint((arrDateDetailsCollection(0))-1)
intDay=cint(arrDateDetailsCollection(1))
intYear=cint(arrDateDetailsCollection(2))
ip_Obj.Click
Wait(intConstShortWaitTime)
intYearFromCalendar=Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebEdit("year").GetROProperty("Value")
intDifOfYears=Trim(intYear)-Trim(intYearFromCalendar)
'<<<If the Year in the input date is more than the present year then it will click on ">>" button and select that particular Year>>>
If (intDifOfYears>0) then
Do while (intDifOfYears>0)
Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebButton(">>").Click
If intYear= Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebEdit("year").GetROProperty("Value") then
Exit Do
End if
intDifOfYears=intDifOfYears-1
Loop
End if
'<<<If the Year in the input date is Less than the present year then it will click on "<<" button and select that particular Year>>>
If(intDifOfYears<0) then
Do while (intDifOfYears<0)
Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebButton("<<").Click
If intYear= Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebEdit("year").GetROProperty("Value") then
Exit Do
End if
intDifOfYears=intDifOfYears+1
Loop
End if
'<<<Select the particualr month as per the user input month>>>
If Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebList("month").Exist(intConstShortWaitTime) Then
Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebList("month").SelectIfNotNull intMonth
End if
'<<<Select the particualr Date as per the user input Date>>>
Browser("Calendar").Page("Calendar").Sync
Browser("Calendar").Page("Calendar").Frame("bottomCalFrame").Link("text:="&intDay).Click
Browser("Calendar").Page("Calendar").Sync
Browser("Calendar").Page("Calendar").Frame("bottomCalFrame").WebButton("Select").Click
'<<<Do Loop for a time of intConstShortWaitTime and get exists when the calendar window gets closed>>>
intMaxWaitCount = intConstShortWaitTime
Do While intMaxWaitCount > 0
If Browser("Calendar").Page("Calendar").Exist(1) Then
intMaxWaitCount = CInt(intMaxWaitCount) - 1
Else
Exit Do
End If
Loop
End Function
'**********************************************************************************************************
'Function Name: Fun_DatePicker(ip_Obj, ip_InputDate)
'Description : Select the Date from the Date Picker on the Screen as per the User Input Date.
'Author: Naresh Gupta. D
'Parameters: Input date, Calendar Object
'Return value 1 for fail
'Example: Call Fun_DatePicker(objCalendar, Parameter("p_AR_RS_NightOfDate"))
'<<<Decleration of Object for Calendar>>>
'Dim objCalendar
'Set objCalendar = Browser("Browser Main").Page("Run Model").Image("Calendar")
'**********************************************************************************************************
Function Fun_DatePicker(ip_Obj, ip_InputDate)
Dim arrDateDetailsCollection, intDay, intMonth, intYear, intYearFromCalendar, intDifOfYears, intMaxWaitCount
Fun_DatePicker = "0"
arrDateDetailsCollection=Split(ip_InputDate, "/")
'<<<Verifying the Month field is numeric or not>>>
If (Not IsNumeric(arrDateDetailsCollection(0))) Then
Fun_ReportFailure "Verify the input passed for Month", "Invalid input passed for Month field and that is : " &arrDateDetailsCollection(0), Nothing
Fun_DatePicker = "1"
ExitFunction
'<<<Verifying the Month field is less than Zero or Empty or Greater than 12>>>
ElseIf arrDateDetailsCollection(0) <= 0 Or arrDateDetailsCollection(0) = "" Or arrDateDetailsCollection(0) > 12 Then
Fun_ReportFailure "Verify the input passed for Month", "Invalid input passed for Month field and that is : " &arrDateDetailsCollection(0), Nothing
Fun_DatePicker = "1"
ExitFunction
End If
'<<<Verifying the Month field is numeric or not>>>
If (Not IsNumeric(arrDateDetailsCollection(1))) Then
Fun_ReportFailure "Verify the input passed for Date", "Invalid input passed for the Date field that is : " &arrDateDetailsCollection(1), Nothing
Fun_DatePicker = "1"
ExitFunction
'<<<Verifying the Month field is less than Zero or Empty or Greater than 31>>>
ElseIf arrDateDetailsCollection(1) <= 0 Or arrDateDetailsCollection(1) = "" Or arrDateDetailsCollection(1) > 31 Then
Fun_ReportFailure "Verify the input passed for Date", "Invalid input passed for the Date field that is : " &arrDateDetailsCollection(1), Nothing
Fun_DatePicker = "1"
ExitFunction
End If
'<<<Verifying the Month field is numeric or not>>>
If (Not IsNumeric(arrDateDetailsCollection(2))) Then
Fun_ReportFailure "Verify the input passed for Year", "Invalid input passed for the Year filed that is : " &arrDateDetailsCollection(2), Nothing
Fun_DatePicker = "1"
ExitFunction
'<<<Verifying the Month field is less than Zero or Empty>>>
ElseIf arrDateDetailsCollection(2) <= 0 Or arrDateDetailsCollection(2) = "" Then
Fun_ReportFailure "Verify the input passed for Year", "Invalid input passed for the Year filed that is : " &arrDateDetailsCollection(2), Nothing
Fun_DatePicker = "1"
ExitFunction
End If
intMonth=cint((arrDateDetailsCollection(0))-1)
intDay=cint(arrDateDetailsCollection(1))
intYear=cint(arrDateDetailsCollection(2))
ip_Obj.Click
Wait(intConstShortWaitTime)
intYearFromCalendar=Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebEdit("year").GetROProperty("Value")
intDifOfYears=Trim(intYear)-Trim(intYearFromCalendar)
'<<<If the Year in the input date is more than the present year then it will click on ">>" button and select that particular Year>>>
If (intDifOfYears>0) then
Do while (intDifOfYears>0)
Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebButton(">>").Click
If intYear= Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebEdit("year").GetROProperty("Value") then
Exit Do
End if
intDifOfYears=intDifOfYears-1
Loop
End if
'<<<If the Year in the input date is Less than the present year then it will click on "<<" button and select that particular Year>>>
If(intDifOfYears<0) then
Do while (intDifOfYears<0)
Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebButton("<<").Click
If intYear= Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebEdit("year").GetROProperty("Value") then
Exit Do
End if
intDifOfYears=intDifOfYears+1
Loop
End if
'<<<Select the particualr month as per the user input month>>>
If Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebList("month").Exist(intConstShortWaitTime) Then
Browser("Calendar").Page("Calendar").Frame("topCalFrame").WebList("month").SelectIfNotNull intMonth
End if
'<<<Select the particualr Date as per the user input Date>>>
Browser("Calendar").Page("Calendar").Sync
Browser("Calendar").Page("Calendar").Frame("bottomCalFrame").Link("text:="&intDay).Click
Browser("Calendar").Page("Calendar").Sync
Browser("Calendar").Page("Calendar").Frame("bottomCalFrame").WebButton("Select").Click
'<<<Do Loop for a time of intConstShortWaitTime and get exists when the calendar window gets closed>>>
intMaxWaitCount = intConstShortWaitTime
Do While intMaxWaitCount > 0
If Browser("Calendar").Page("Calendar").Exist(1) Then
intMaxWaitCount = CInt(intMaxWaitCount) - 1
Else
Exit Do
End If
Loop
End Function
Hi Naresh...
ReplyDeleteDate calendar click...In Date picker window Two months appearing...
I written the code for MakeMyTrip site...but can able to select current month only...
i want select next month date... and Both WebTable properties are same...
How can i achieve this...
= Below the code....
Browser("name:=MakeMyTrip.").Page("title:=MakeMyTrip.").WebElement("outertext:=DEPARTURE.*","index:=0").Highlight
wait 1
Setting.WebPackage("ReplayType") = 2
Browser("name:=MakeMyTrip.").Page("title:=MakeMyTrip.").WebElement("outertext:=DEPARTURE.*","index:=0").Click
Setting.WebPackage("ReplayType") = 1
'Getting a today date with plus 10 days extra
idate=date() + 10
idatevalue=Split(idate,"/")
idateval=Trim(idatevalue(0))
Print("given date is - "&idateval)
'''Getting the today date row n the From Webtable
Browser("name:=MakeMyTrip.").Page("title:=MakeMyTrip.").WebTable("column names:=Su;Mo;Tu;We;Th;Fr;Sa","index:=0").Highlight true
wait 1
row=Browser("name:=MakeMyTrip.").Page("title:=MakeMyTrip.").WebTable("column names:=Su;Mo;Tu;We;Th;Fr;Sa","index:=0").GetRowWithCellText(idateval)
print ("Row count is - " & row)
'''Getting the column count for the todays date row
ccount=Browser("name:=MakeMyTrip.").Page("title:=MakeMyTrip.").WebTable("column names:=Su;Mo;Tu;We;Th;Fr;Sa","index:=0").ColumnCount(row)
Print ("Column count is : - " & ccount)
For i=1 to ccount
CellData = Left(Browser("name:=MakeMyTrip.").Page("title:=MakeMyTrip.").WebTable("column names:=Su;Mo;Tu;We;Th;Fr;Sa","index:=0").GetCellData(row,i),2)
Print ("cell data is : - " & CellData)
If CellData=idateval Then
Setting.WebPackage("ReplayType") = 2
Set iObj = Browser("name:=MakeMyTrip.").Page("title:=MakeMyTrip.").WebTable("column names:=Su;Mo;Tu;We;Th;Fr;Sa","index:=0").ChildItem(row,i,"WebElement",0)
' CellDate highlight before select the date
iObj.Highlight
wait 1
iObj.Click
Setting.WebPackage("ReplayType") = 1
Exit For
End If
Next
Plz if your are free...can check update
ReplyDeleteit useful for all...Thanks