Automating Date Control using QTP


Please help me in automating date control object using QTP.

I’m trying to automate date control as it picks the user required date (** can be from previous year too) during run time. But I couldn’t achieve it by using the date control object, as that IMAGE object doesn’t have any in-built operations to select required.

Note: Textbox is disabled and so we cannot enter the date into it directly, so we should select the required date from the calendar object. Thanks!

27-Mar-2015: Updating with AUT screen for more clarity

Here is the date control I’m trying to automate, prior to this application, I just used to add the textbox control and SET the required date into it. But in this case, the textbox is not editable, and so we I have to pick the date from the date control object – most the dates (inputs) are from past years.

So I just tried to capture the control object and it’s got recognized as IMAGE, using which I couldn’t perform only the click action.

enter image description here

Please check and help. Thanks!

  • You must to post comments

Just a quick workaround to enable the calendar textbox & to enter the value

Browser(..).Page(..).WebEdit(...).Object.disabled = False
Browser(..).Page(..).WebEdit(...).Set "12/12/2000"
  • You must to post comments

Answer :
From UFT 12 version onwards, we can hit java script to identify an object. Please refer below code.

‘Click on Calendar text box/Datepicker

‘click on the <> arrow to move month

‘Get the month
objMonth = Browser().Page().WebElement().GetRoProperty(“Text”)

‘suppose that you want to select date as – 1st January
If objMonth == “January” Then
objDate = Browser().Page().WebElement().GetRoproperty(“Text”)
If objDate == “1” Then
End If
End If

  • You must to post comments
Showing 2 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.