Forum Discussion

OV's avatar
OV
Frequent Contributor
7 years ago

Why can't i concatenate object string

Please look at the attached and tell me why i can't concatenate object hierarchy?

 

why 

 

TheObjectToClick = Aliases.QuickDesign_ConfigurationManager.OverViewScreen.ProjectsButton

 

and TheObjectToClick.Exists is undefined?

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    First of all, I'm assuming you're actually passing in an actual onscreen object as the "Object" parameter?  If not, I would suggest you change it to a string equaivalent to the name assigned to that object in your Aliases.  

     

    Secondly, you need to make sure that, for example, if your object is "myObject", that there is actually an Alias for 

     

    Aliases.QuickDesign_ConfigurationManager.OverViewScreen.myObject 

     

    in your Aliases under NameMapping.

     

    Finally.... it's still a string.  You need to evaluate it into an object.  You could use the "eval" method of JavaScript to evaluate the string into an object... but, honestly, that feels cumbersome to me.  I'd recommend the following code instead.

     

    function ClickObjectInHomeScreen(objectName){
        var theObjectToClick;
        theObjectToClick = Aliases.QuickDesign_ConfigurationManager.OverViewScreen.WaitAliasChild(objectName, 20000);
        if (!theObjectToClick.Exists){
            Log.Error('The object with name ' + objectName + ' could not be found);
        }
        else {
            theObjectToClick.Click();
        }
    }

    The "WaitAliasChild" method will check to see if a child of the OverViewScreen with the name of objectName exists.  If it doesn't, we'll log the error.  If it does, we do the desired click.

     

    Give this a try.