Forum Discussion

lansanniu's avatar
lansanniu
Occasional Contributor
8 years ago
Solved

name mapping ,change the value of an identification property

like the pic attachments

 

-----------------------------------code start---------------------------------------------------

def clickbutton():
   Project.Variables.var1 = "1"   #time1
   Aliases.LockControlSimulator.xxx.BoxControl.button1.ClickButton()

 

   Project.Variables.var1 = "2"   #time2
   Aliases.LockControlSimulator.xxx.BoxControl.button1.ClickButton()

-----------------------------------code end---------------------------------------------------

 

time1 and time2 is click the same button, I wish it can click the button I set

after it run, the value of the button property will always "1" ,until I restart TC

 

How can I make the value refresh?

this problem makes me cracy, help me please!

  • This is a mapped object right?

     

    In which case, this: https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/refreshmappinginfo-method.html

     

    .. .might help?

     

    Additional thought, your mapping appears to be to the container object that holds the button yes? That's the part with the dynamic identification property here? In which case, just ignore it. Search for the button directly from "panel1" (whatever that is - the parent object of the button container). Do a 2 level deep search for the button and the properties on the container cease to matter.

     

    Unless there is something I'm not aware of preventing you from doing this ....

     

    (I'm not clear exactly whats going on here. Do you have one button, which has dynamic properties? Or two buttons, with very similar properties, which you are trying to use a single name map for? If it's two buttons, are they present at the same time? Or is only one of them ever present? All these factors affect how you'd approach this ...)

8 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Not sure if I got the problem right, but some quick idea:

    Considering that Index is an integer property, what if you replace

    Project.Variables.var1 = "2"   #time2

    with

    Project.Variables.var1 = 2   #time2

    ?

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      ^^^ Ha ha! I didn't even notice that! :D

       

      (Still think a helper function is the better solution in this case tho ....)

    • lansanniu's avatar
      lansanniu
      Occasional Contributor

      No,this Index is an string  property。

      the problem is the value of the property cannot refresh

      , once be setted, no matter how many times you set, it will always the first value

       

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hm-m-m...

        Then, maybe, this is something that should be reported to Support? (Use https://support.smartbear.com/message/?prod=TestComplete form for this.)

        I used this functionality in several projects to identify the web page and it worked stable and reliably for me. (Though I a) did not verified it with the latest TC12.1 and b) change the value of the variable used for page object identification only two or three times within the test cycle that takes approx. 40 minutes to run.)

  • This is a mapped object right?

     

    In which case, this: https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/refreshmappinginfo-method.html

     

    .. .might help?

     

    Additional thought, your mapping appears to be to the container object that holds the button yes? That's the part with the dynamic identification property here? In which case, just ignore it. Search for the button directly from "panel1" (whatever that is - the parent object of the button container). Do a 2 level deep search for the button and the properties on the container cease to matter.

     

    Unless there is something I'm not aware of preventing you from doing this ....

     

    (I'm not clear exactly whats going on here. Do you have one button, which has dynamic properties? Or two buttons, with very similar properties, which you are trying to use a single name map for? If it's two buttons, are they present at the same time? Or is only one of them ever present? All these factors affect how you'd approach this ...)

    • lansanniu's avatar
      lansanniu
      Occasional Contributor
      Colin_McCrae,thank you very much, it helps ,TestObj.RefreshMappingInfo() now I know ,once the identification property is setted, it can not be reset, unless you restart TC ,or use TestObj.RefreshMappingInfo() this case, it is a panel with 30 buttons, parent node is BoxControl, I want to use a dynamic identification property to match one of it. "Aliases...xxx...BoxControl.index" is 1 to 30
      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        Sounds like something I'd use a helper function for if very little is different/changes between the buttons.

         

        Seems a little cumbersome to map 30 of them and then use a dynamic property to identify each one. If I've understood what you're working with (not 100% sure I have), it sounds like mapping as far as the top level container, then finding the relevant button on the fly at runtime would be easier.