Micro Focus QTP (UFT) Forums
Select Current Date from a Calendar Control - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Select Current Date from a Calendar Control (/Thread-Select-Current-Date-from-a-Calendar-Control)

Pages: 1 2


Select Current Date from a Calendar Control - qtpbeginner78 - 05-27-2013

Hi All,

I need to select the current date from a Calendar control on my web application. Please see the attachment to get an idea of what i want to perform.

Appreciate if someone can help me on this.

Thanks a lot.


RE: Selct Current Date from a Calendar COntrol - ssvali - 05-27-2013

I think in this case, you might go with Descriptive programming instead of using OR.


RE: Selct Current Date from a Calendar COntrol - qtpbeginner78 - 05-28-2013

Thanks ssvali for your reply.

I found a way to handle it. Below is the code i use

1. I had to set the focus on the webedit so it will pop-up the calendar control

Code:
Browser("br_xyz").Page("pg_abc").WebEdit("we_EndTime").FireEvent("onclick")

2. Select the current date

Code:
Browser("br_xyz").Page("pg_abc").WebElement("innertext:=" &Day(Date),"html tag:=DIV").Click


Hope this will help others too Smile


RE: Selct Current Date from a Calendar COntrol - ssvali - 05-28-2013

Its good that you find solution by ur own.

So u added the object to OR and then clicking it. What if in future if the requirement change.

say for ex:- Today's requirement is to click on current data but the if requirement change to click on some other date provided by user.

What i suggest you that write to function to click any given date in the calendar.


RE: Selct Current Date from a Calendar COntrol - venugqtp - 05-28-2013

Hi I think he handled the situation correctly, Please have a look another time he used inline description program to select the date

Code:
Browser("br_xyz").Page("pg_abc").WebElement("innertext:=" &Day(Date),"html tag:=DIV").Click

Here 'Day(Date)' will generate day from today's date in case if he needs to select a day from his own

Code:
iDay = 26

Browser("br_xyz").Page("pg_abc").WebElement("innertext:=" &iDay,"html tag:=DIV").Click
Hope this understand...


RE: Selct Current Date from a Calendar COntrol - ssvali - 05-28-2013

Got it . Thanks for explanation.

I think i missed "&Day(Date)" while looking at earlier post.

But any have Thanks once again and sorry for inconvenience.

Regards,
Shashavali


RE: Select Current Date from a Calendar Control - qtpbeginner78 - 05-29-2013

Thank you both for your replies.

Now im having this issue randomly. Calendar control will pop-up but sometimes it will not select the day although i have instructed QTP to click on the day. (pop-up will stay as it is without selecting the day and focus will go to next field)

I have no idea why this is happening.

Any ideas?


RE: Select Current Date from a Calendar Control - venugqtp - 05-29-2013

you can try below scenarios

1.
Code:
Add webtable to OR
Browser("br_xyz").Page("pg_abc").WebTable("Webtable").WebElement("innertext:=" &Day(Date),"html tag:=DIV").Click

2. you can try highlight(This will help to pen down the issue)
Code:
Browser("br_xyz").Page("pg_abc").WebElement("innertext:=" &Day(Date),"html tag:=DIV").highlight
Browser("br_xyz").Page("pg_abc").WebElement("innertext:=" &Day(Date),"html tag:=DIV").Click



RE: Select Current Date from a Calendar Control - qtpbeginner78 - 05-30-2013

Thanks for the reply. But unfortunately calendar control is not highlighting.

How can i add the webtable to the OR. It has two web tables. (see the screenshot)

I think application is behaving in a funny way. When i navigate to another page of the application it won't identify any objects in the page. This happens for that particular page only.

I am lost now.


RE: Select Current Date from a Calendar Control - supputuri - 05-30-2013

Follow the below steps

1) Identify the Calendar window(identifies as WebElement) - Use Developer tool bar to found out the properties but not qtp spy
2) Conditional statement to check if the Calendar exist
3) Click on the Weblement using class and innertext along with Index:=0 (as there are some situations where the calendar will display more than one 7 - eg: if you click on your system date today you will find two 7s')

Let me know if you need any help