Forum Discussion

m_essaid's avatar
m_essaid
Valued Contributor
8 years ago

name mapping - similar objects

Hi,

 

I have a windows that could have a "Yes" button, or an "OK" button.

 

(see picture attached please).

 

The problem is that TC wants me to update the objects properties. But there is no ambiguity : sometimes I wait for "OK", other times for "YES". And I know that it's the same window (mapped with WndClass and WndCaption).

 

Did I miss something ?

 

Tthank you for your help,

 

Mehdi

  • Hey Robert, thank you for your help, you helped me to figure it out. The WaitAliasChild function was not used properly...

    You can see the right script attached.

    Thank you again,

    Mehdi

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Hey Robert, thank you for your help, you helped me to figure it out. The WaitAliasChild function was not used properly...

    You can see the right script attached.

    Thank you again,

    Mehdi

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The window may be the same window... but there are, technically, two different buttons, one that is "Yes", one that is "OK".  The problem is not that it's having problem identifying the window but problem identifying the button.  You can handle this two ways.

     

    1) Map both buttons so that your window has "buttonOK" and "buttonYes".  Then, in your code, you click on which ever button is necessary at that point in the code.  

    2) Map the button with Conditional Mapping (https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/managing/modifying/conditional-mapping-criteria.html) where you map the button to be the button you're looking for if it is "Yes" OR "Ok".

    • m_essaid's avatar
      m_essaid
      Valued Contributor

      hi Robert,

       

      For the first point I already done that, see attached picture please.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        So, basically, when you run your automation, you need to specify which button to click.  If you attempt to click "Yes" and the "OK" button is what is displayed, then you'll get the message that you saw in the test log because TestComplete says, "I couldn't find the one you said should be there, but I found one similar."  It means that your code doesn't match the application behavior.  So, the correction to your problem in your OP is to change your code from

         

        TMessage2.Yes.ClickButton

         

        to

         

        TMessage2.OK.ClickButton