Forum Discussion

shiva_ranabhat's avatar
shiva_ranabhat
Contributor
11 years ago

How to set textnode/panel as a variable?

Hi,



Is there any way I could set this "textnodeCustomerService" as a variable in Project Suit and call it there?



We can use actual values as a variable but I'm not sure if we can set identifier as a variable.







Thanks,

Shiva

6 Replies

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    You need to use eval() to assign the value to your object variable.  That tells TestComplete to treat the string as an object.



    These attached examples are in keyword tests but you can see the scripting in the Code Expression.  

  • Hi Tanya, 







    I get an error: Unable to find object team





    var team= ProjectSuit.Variables.Organisationnode ;


    textNode = form.panelLeftcontent.panelTree.panelXPanelXTree.panelXTreeNodeElXUnselectableXTr.team;


      textNode.Click();



    Is that how I should call it?


  • Hi Shiva,


     


    You need to assign your object to the variable. Judging by the image, you didn't assign anything to Organisationmode. Once you do it, you can access the object's methods and properties in the following way:




     


  • Hi Tanya, 



    Thank you for the reply. But we can't actually assign value to an object type variable. 







    We can only assign it a value in the script this way, which will be meaningless since we have to assign it value in every single test scripts. 





    and this way assigning value returns an error..







    Regards,

    Shiva 

     



  • Thats what I was looking for. Thanks Marsha.



    Now I will need to set Name mapping for all the new variables identity, then it should be fine to run test in different environments with different front-ends, with just the matter of twerking of project suite variables. Fantastic! 



    Thanks,

    Shiva