Forum Discussion

kevin_kapell's avatar
Frequent Contributor
8 years ago

How can I make selections in the Xdsoft DateTimePicker?

How can I make selections in the Xdsoft DateTimePicker? Our code uses this picker and I cannot seem to code TestComplete Scripts correctly to pick a specific date.

An example of this input field can be found in the link below.

  • Colin_McCrae's avatar
    8 years ago

    I'm not seeing the problem?


    I had a quick go at the example one you provided. Two quick hack-together solutions. All using C# Script I'm afraid as that's what my current project is using. Should be simple enough to convert.


    First one. Assigns the Picker text field to an object. Uses SetText to empty it. Then uses Keys + Tab out to set the new value. So as if the user typed it. Works fine for me.


      var Picker_Field = Sys["Browser"]("chrome")["Page"]("")["Panel"](2)["Panel"](0)["Panel"](0)["Panel"](0)["Panel"](0)["Panel"]("main")["Panel"]("maininner")["Section"]("content")["Panel"]("system")["Article"](0)["Panel"](0)["Textbox"]("datetimepicker");
      Picker_Field["Keys"]("2016/12/25 11:11[Tab]");


    Second one. Uses the two back/forward buttons either side of month/year to cycle through 12 months until it gets a match. Then logs if it found a match or not. Has to click a day for the value to be retained by the text field so I have a day cell hard-coded in. If I wanted to do full automated control of it, I'd have to search the cell objects (use a Find method or whatever) to find the correct one, but you get the idea. Again, works fine for me. It clicks until it finds "December" (the value I've set it to search for), clicks a Day cell. Value is retained in the text field.


    If you were having problems only trying to change the month, that's probably because the text field doesn't retain the value if you ONLY cycle through the months. The value is retained when you click on a date cell in the table below. Try it manually. Same thing. It won't retain unless you click an actual Date.


     var Month_Back = Sys["Browser"]("chrome")["Page"]("")["Panel"](11)["Panel"](0)["Panel"](0)["Button"](0);
      var Month_Forward = Sys["Browser"]("chrome")["Page"]("")["Panel"](11)["Panel"](0)["Panel"](0)["Button"](2);
      var Current_Month = Sys["Browser"]("chrome")["Page"]("")["Panel"](11)["Panel"](0)["Panel"](0)["Panel"](0)["TextNode"](0);
      var Day_Cell = Sys["Browser"]("chrome")["Page"]("")["Panel"](11)["Panel"](0)["Panel"](1)["Table"](0)["Cell"](2, 3); 
      var Desired_Month = "December";
      var Month_Match = false;
      var Month_Text = "";
      for(var Month_Loop = 1; Month_Loop < 13; Month_Loop++) {
        Month_Text = Current_Month["contentText"];
        if(Month_Text == Desired_Month) {
          Log["Message"]("Month found!");
          Month_Loop = 13;
          Month_Match = true;
        } else {
      if(!Month_Match) {
        Log["Message"]("Month not found ... :(");
      } else {


    Normally, I wouldn't hard code all the values and object ref's, but this is a quick knock together example.


    So I'm not sure where you're hitting problems. (Should probably add, I'm using TC11.30 and Chrome)

4 Replies

    • Colin_McCrae's avatar
      Community Hero

      I just had a look at the example one and was able to see all the buttons and text fields for changing the month etc and a table with individual cells for all the days within the month.


      I can see how I could write something that goes through these components finding the bits I want. Might be a little fiddly, but I can see how I could do it.


      Where are you hitting problems?


      Do you need to use the picker? It's a ready-made component, so I can't imagine you're testing it in it's own right. In which case, just blank the field and set the value using text. If you're not testing the actual picker, why bother using it if you don't have to?

      • kevin_kapell's avatar
        Frequent Contributor

        I am not testing the picker itself but I do need to set a known date for testing the place it is being used. I tried just clicking in the field and using the keys command to type in a date but after selecting enter the date goes to the current date/time. This happens on the sample page as well.


        While I can map the various objects I am having a problem actually selecting a specific value. The first one is trying to select a month other then the current month of September. I have not tried selecting the year or day yet.


        I simply need to be able to enter a known future date in which ever manner I can.