Forum Discussion

anumolu9999's avatar
anumolu9999
Contributor
8 years ago

Accessing NameMapping objects in scripts

Hi, I had given the NameMapping alias name to a variable like aliasName="Aliases.page.button" Here actually I am passing text to the variable in above step. can i access the NameMapping object using above variable to do actions on the object. Thanks, Anumolu
  • Hi Anumolu,

     

    If I got the question right:

    Use eval() or evaluate() function (depending on the language of your test project, e.g.: http://www.w3schools.com/asp/func_eval.asp) :

    I.e.:

    VBScript - Set aliasName = Eval("Aliases.page.button")

    Other languages - aliasName = evaluate("Aliases.page.button")

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Anumolu,

     

    If I got the question right:

    Use eval() or evaluate() function (depending on the language of your test project, e.g.: http://www.w3schools.com/asp/func_eval.asp) :

    I.e.:

    VBScript - Set aliasName = Eval("Aliases.page.button")

    Other languages - aliasName = evaluate("Aliases.page.button")

    • anumolu9999's avatar
      anumolu9999
      Contributor
      Hi Alex, Thanks for the reply.... Actually, I want to find whether the screen control exists or not in a windows application screen. So I kept all the aliases names of objects in excel and want to read the aliase name, and want to find whether the object exists or not in the screen. This is the hierarchy of the control in the namemapping: Aliases.MCFConfigTool.MCTWindow.MainWindow.workspace.LogDurationValue I passed this as text to a variable as below aliasName="Aliases.MCFConfigTool.MCTWindow.MainWindow.workspace.LogDurationValue" Can i make the aliasName as an object variable from string variable to perform actions on the object(Exists, click, settext) as Below: if(aliasName.Exists==true) Is there any way to do like this Thanks, Anumolu.
      • baxatob's avatar
        baxatob
        Community Hero

        You can simply do:

         

        element = eval("Aliases.MCFConfigTool.MCTWindow.MainWindow.workspace.LogDurationValue")
        
        if element.Exists:
            do_something()