cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript call to date picker function

Senior Member

Javascript call to date picker function

I'm new to TestComplete.  I'm learning Javascript to address issues when TC cannot address certain objects.  I have a problem trying to input a date into a field.  The field will not accept manual input.  SetText and Keys do not work.  You have to use the date picker to populate the field, but TC cannot map the object (very strange).  The object uses a angular js to launch the calendar.  I've search the google-verse and cannot find a solution. Everything suggestion I have tried through javascript has failed (mostly Javascript Runtime errors).  I would have liked to provided html codes samples, but the environment is in a VM and security disallows copy/paste between environments.

2 REPLIES 2
Community Hero

Re: Javascript call to date picker function

What other properties/methods are available?  Anything like a wText or wDate?  Anything like a "set date"?

What I've had to do in the past is create a wrapper function to allow me to interact with similar components... It would be like "setCalendarDate" where it would take the component and the desired date as parameters and then go through some native objects and methods to perform the action.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Hero

Re: Javascript call to date picker function

Hi,

 

While this might not work in your specific case, but it worked for me in many cases.

-- Enter manually some date into the field;

-- Locate the field using Object Spy and investigate it in the Object Browser. Your goal is a property that contains entered date. (Usually it is named as 'value'.)

 

Now in test code you should do the following:

-- Locate the field and assign required date value to the found property (e.g. <control>.value = '31/01/2019');

-- Click the control or press Alt-Down or perform any other action that will open date picker control;

-- When opened, the date picker control usually has the entered date pre-selected;

-- Press Enter key to confirm date selection in the picker. This should trigger internal page code that will do all required actions/assignments/etc.;

-- After the above sequence the control usually contains entered value that is correctly recognized and processed by page script code.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
February News
Top Kudoed Authors