Forum Discussion

MulgraveTester's avatar
MulgraveTester
Frequent Contributor
9 years ago

Test exact text shown in time fields

Time fields have the wTime property instead of a wText property. I can test that they show the correct time value but I want to ensure that it displays correctly. I want to ensure that seconds are not shown and leading zeros are shown.

 

e.g. My field shows "02:34 PM" but the wTime property in the object spy shows "2:34:00 PM". I want to test that the field is displayed as it is now.

 

Is there a way (other than using text recognition) to test the exact text of a time field? i.e. Can I get the equivalent of a wText property in a text field?

2 Replies

  • MulgraveTester's avatar
    MulgraveTester
    Frequent Contributor

    When using Text Recognition it is necessary to piece back together the text that the field displays because they are stored as separate entities "02", ":", "34", " ", "PM". Here is my code that returns the string displayed in a text field:

     

    function timeText(fieldObj)

    'Returns the text string displayed in a time field object

    timeText = ""

    for each textObj in fieldObj.findallchildren("Name", "TextObject*")

    timeText = textObj.text & timeText

    next

    end function

     

    There has to be a better way than using text recognition

     

    • MulgraveTester's avatar
      MulgraveTester
      Frequent Contributor

      Woops. It is also necessary to sort the text objects from left to right because they can be can come in any order. See it gets messy using text recognition.