Forum Discussion

DainiusA's avatar
DainiusA
Contributor
4 years ago
Solved

Log version number in an app

Hello,

 

I am new to the scripting so sorry for this kind of questions, i am trying to log the current version of the desktop app, but can't find a way how to do it.

So i have an app that has a version (picture Version.png). The i try to select it, i can only select the whole line and that makes my object look in NameMapping like this:["Sys"]["Uvs_WinPos"]["HwndSource_Cashier_480x320"]["Cashier_480x320"]["ActiveItem"]["TextblockVersija10740429807"].

 

And then i made a script that checks that version contains the desired Text: ["Uvs_WinPos"]["HwndSource_Cashier_480x320"]["Cashier_480x320"]["ActiveItem"]["TextblockVersija10740429807"], "Text", cmpStartsWith, "Versija:");

 

But the i change the version i am getting this kind of error: Unable to verify a value with the property checkpoint, because the target object does not exist. 11:21:31 Normal 0.00.

 

So how can i get the version number from that block no matter what it is and log it ?

 

Best regards,

Dainius

  • I see your problem right away in your Version2.png.

    You are using the property WPFControltext and the value you have in your mapping is the version number that keeps on changing.

    I would do  two things for your mapping.

     

    1) Rename the mapped object from TextblockVersija10740527226 to simply TextblockVersija.  Be sure you also delete all other mappings of the object as they are, essentially, useless

    2) Edit the properties.  Delete the "Name" property.  It's generally unecessary.  And edit the WpfControlText property and, in the value, replace "1.0.7405.27226" with the asterisk (*) symbol.  This wildcards the version number.  The mapping will find the object based upon the ClrFullClassName and the Control text that contains the word Versija.

     

     

    The general principle to learn is that, when mapping objects, you need to make sure that the properties you're using are not changing from one version to the next.  If they are, you have two choices.  Either select a different set of properties or wildcard the section of the property value that is changing.

     

    Please let me know how this works.

8 Replies

  • Wamboo's avatar
    Wamboo
    Community Hero

    Hi,


    Possible solutions:


    1) Enable this option and check that TextObject() -> search for it using findxxx().

     

    https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/text-recognition/index.html


    2) You get an error because you are trying to verify an object with the parameter 'TextblockVersija10740429807' and it does not exist when you change the current version number. Try mapping the object to NameMapping after the version change. You may notice that there is another object, not the previous one.


    What you can do is map this area for reading and search the text inside the property -> read it -> do a regexp to verify it and you are ready to go.

    • DainiusA's avatar
      DainiusA
      Contributor

      Hello,

       

      Sorry, but i am a little bit confused.

      1) As i can see i have enabled text recognition. But can't uderstand how to search for the TextObj()

       

      2) I don't want to map versions every time, because they are changing sometimes 10 times a day. Is thre some kind of way to bypass that ? Is there any kind of documentation what is regexp and how to use it ?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        What criteria are you using for your mapping (properties)?  Because each time the version changes, if you are using the version number as a mapping criteria, you're never going to find the text.

        To be able to help you best, it would be nice to see:

         

        1) In Object Browser, how does that component show up?  Please screenshot the properties, being sure to include "Advanced" view to see all available properties.

        2) When mapping, what is the hierarchy and property set that you have selected?  Screenshot your Mapped Objects section of your NameMapping tab being sure to show the tree of objects and the properties and values you're using to map the object.