Forum Discussion

Ryu's avatar
Ryu
Contributor
6 years ago
Solved

Using the Find method when several screen objects have same namemapping

I am testing a web page that has several elements mapped to the same name (all of the checkboxes have different contentText values but are all mapped to page.checkboxObject and all of the buttons on the same page have different captions, but are all mapped to page.saveButton).  I am trying to use the Find method to differentiate between the checkboxes/buttons, but I seem to be doing it wrong.  Can you guys give me tips on how to use it?  The examples on the SmartBear website aren't clearing the issue up for me.  

 

Here is how I am currently trying to use it (python):

 

checkboxA = process.checkbox.Find("contentText", "text")

 

The test log says it can't find the referenced object on the screen.

  • It sounds like the problem is in your mapping, that the components are not being mapped uniquely enough.

    Couple of things:

     

    1) Go to Tools | Options | Engines | NameMapping and turn off the "Use extended find whenever possible" check flag.  Extended find is a good feature but, especially when recording tests, it can cause issues by collapsing the tree of ancestor objects TOO much

    2) Go to your NameMapping node and find the checkbox object in question.  If the "Extended Find" flag is turned on, you will need to remap the object after performing step 1 to give a better identification.

     

    Basically, TestComplete's NameMapping uses two main pieces of data to identify an object: 1) the ancestor/parent of the object and 2) the property/value pairs for the object.  So, what it sounds like is that some of the ancestor objects between the main form and the checkboxes have been "collapsed" from the Extended Find so, when searching for the checkbox, each one is found by the same NameMapping criteria.

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    It sounds like the problem is in your mapping, that the components are not being mapped uniquely enough.

    Couple of things:

     

    1) Go to Tools | Options | Engines | NameMapping and turn off the "Use extended find whenever possible" check flag.  Extended find is a good feature but, especially when recording tests, it can cause issues by collapsing the tree of ancestor objects TOO much

    2) Go to your NameMapping node and find the checkbox object in question.  If the "Extended Find" flag is turned on, you will need to remap the object after performing step 1 to give a better identification.

     

    Basically, TestComplete's NameMapping uses two main pieces of data to identify an object: 1) the ancestor/parent of the object and 2) the property/value pairs for the object.  So, what it sounds like is that some of the ancestor objects between the main form and the checkboxes have been "collapsed" from the Extended Find so, when searching for the checkbox, each one is found by the same NameMapping criteria.

    • Ryu's avatar
      Ryu
      Contributor

      tristaanogre, I ended up having to delete the original mapped object and then manually remapping all the checkboxes separately.  I do have a few tests to update because of this change, but I would rather do that than rely on screen coordinates.  Thanks for helping me figure out the issue.  :)

    • Ryu's avatar
      Ryu
      Contributor

      I turned off the extended mapping in Tools like you said, tristaanogre, but when I went to remap the checkboxes, they were still all mapping as the same item.  Is there a TestComplete method I can use to differentiate?  Can I not do it with the Find method?