Forum Discussion
Sorry for late response.
But it did not work. But If I write below command in developer tool's console window then it works on browser.
document.getElementById('txtDepartureDate').value = "08/03/2017"
Is it possible to write above Javascript statement into my VBScript Project of TestComplete?
On link https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html there is solution to run javascript function exist in Application Under Test. How can I execute javascript statement?
Thanks,
Abhay Kulkarni
Hi,
Try to set the value directly. E.g.:
Aliases.browser.yourTargetElement.value = "08/03/2017" where yourTargetElement is the mapped name
of the element with id "txtDepartureDate"
- baxatob6 years agoCommunity Hero
Hi,
The implementation of clicking on particular date depends on how the date is represented in you datepicker - separate days, months and years, or may be some elements are grouped by some logic. It is difficult to say how to do it without seeing the web element and its properties.
Usually direct setting of the date (using JS or element's value attribute) - the most easy, fast and reliable way.
- tristaanogre6 years agoEsteemed Contributor
For the most part, keep in mind, you're not testing the component itself. It sounds like it's a pretty standard component that developers drop in. Your goal is to test the functionality of what happens when a particular date is set. So, setting the value is an efficient way of doing so without getting bogged down in trying to figure out how to automate the component.
- amitkumarlogs6 years agoNew Contributor
baxatob Thank you so much, its working fine for me. It will be really helpful if you could help me out to do it by clicking on particulate date from calender picker.
- amitkumarlogs6 years agoNew Contributor
baxatob I tried to set the value directly using the below piece of code, it display the value in the field once this code runs, but the problem is when I navigate to next page "To find the flights for date 13 sep 19" then I cant see the result for 13 Sep 19. Instead it is showing the flight on basis of current system date. Meaning that its not storing the value which i am providing instead taking the default current date.
var departureDate=page.NativeWebObject.Find("idStr","departureDate"); departureDate.value="13 Sep 19";Please find the snapshot of my calender
Please help me do select the date from calender as i got stuck to move forward.
- tristaanogre6 years agoEsteemed Contributor
It is possible that there is an "OnExit" event on the data field to make sure that it is updated once you set the value. Examine the events and methods on the object to see if you can find such an event and explicitly call it after setting the value.
- AlexKaras6 years agoCommunity Hero
Hi,
As I wrote initially (https://community.smartbear.com/t5/TestComplete-Functional-Web/Did-any-one-find-solution-to-select-date-from-date-picker/m-p/145323/highlight/true#M30169), note that correct date is pre-selected in the calendar panel after you assigned the value to the text field. Thus try to confirm the date by pressing Enter for either the text field or calendar panel to confirm selection in the panel and give a chance for the page script code to perform all expected internal assignments.