Forum Discussion

harmatii's avatar
harmatii
Occasional Contributor
5 years ago
Solved

Not able to add objects like "OCR.Recognize(Aliases.EXCEL...).BlockByText("..ook")" to Name Mapping

Using TestComplete to create automate Excel Addins I have trouble to save my objects to Name Mapping

 

OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("Home").Click()
OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("Insert", spLeftMost).Click()
OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("Page Layout").Click()
OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("Formulas").Click()
OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("Data").Click()
OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("Review").Click()
OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("View", spNearestToCenter).Click()
OCR.Recognize(Aliases.EXCEL.wndExcel.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND).BlockByText("Help").Click()

 

TestComplete is not adding this objects automatically to the Name Mapping.

  • You don't.  At least, not in NameMapping.

    NameMapping is for recognizing, finding, and identifying objects on screen for interaction in the automation.  If you're doing OCR.Recognize, that's returning an object, sure, but it's not a UI object.  So, you would use your standard coding technique of assigning to some sort of variable.  You could create an array and "push" each one to an element in the array.  You could create a dictionary and added a key/value pair for each object... all sorts of methods for storing the object during code execution.

     

    But you would NOT use NameMapping.

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    OCR.XXXX objects are not onscreen objects therefore they will not be added to NameMapping.

    • harmatii's avatar
      harmatii
      Occasional Contributor

      What way would you recommend to store objects like that? 

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        You don't.  At least, not in NameMapping.

        NameMapping is for recognizing, finding, and identifying objects on screen for interaction in the automation.  If you're doing OCR.Recognize, that's returning an object, sure, but it's not a UI object.  So, you would use your standard coding technique of assigning to some sort of variable.  You could create an array and "push" each one to an element in the array.  You could create a dictionary and added a key/value pair for each object... all sorts of methods for storing the object during code execution.

         

        But you would NOT use NameMapping.