Forum Discussion

anhhao_nguyentr's avatar
anhhao_nguyentr
Occasional Contributor
11 years ago

Map object

Hi all,

How to map a object (button) base on the label/text?

I think the label is more stabilizer than the index or the other properties.





  • Hey,



    If it is possible, I always use label or caption of a button object to map it, because there is a bigger chance that the caption will not be changed in future. Actually for every object I rather use its caption.
  • Mia's avatar
    Mia
    Contributor
    Hey,



    If it is possible, I always use label or caption of a button object to map it, because there is a bigger chance that the caption will not be changed in future. Actually for every object I rather use its caption.
  • Yeah, when mapping buttons I generally use the WndClass and WndCaption of the object. In the Object Name Mapping dialog you can select which properties to use to map the object, so select the ones least likely to change but which are still unique. 
  • OK, if the caption is not recognized for the object then you could use the text recognition plug-in (should be installed by default). This allows the text of the object to be captured by TestComplete. 



    Using the Calculator as an example, the number buttons are "WndClass: Button", so:



    Right Click on Project folder > Edit > Properties

    Open Applications > Text Recognition > add the Button class



    Now when you spy the buttons the text will also be highlighted (see image) so can be mapped.



    The parent object won't be unique if you removed the index or other unique identifier so you would need to do some further work, maybe FindChild["Text", "1"] to check for the number 1 button? 



    Edit: Link for the Text recognition overview



    http://support.smartbear.com/viewarticle/56486/
  • anhhao_nguyentr's avatar
    anhhao_nguyentr
    Occasional Contributor
    Thank you for your comment, ^.^

    But i see that Testcomplete can not recognize the caption of some button (you can check it on Calculator application), thus we have to use other properties and it is not expected.