Forum Discussion

umair_chagani's avatar
New Contributor
12 years ago

Get control via method in c#


I'm trying to build a flexible library that we can use via TC's Connected Application.

I know that to retreive a control in C# I would do:

var x = Aliases["Blah"]["blah"]["blah1"]

Is there a way to do the same thing via method call?  Something like:

var x = Connect.GetObject("Blah.blah.blah1");

This is just an example so you know what I would like to do.  I'm not sure if GetObject is the right method to use for this sort of thing (or if it's even possible).  Getting an object via  method call  by passing in a string for alias or some other way to pass in a string to get an object will make my life a lot easier.

3 Replies

  • TanyaYatskovska's avatar
    SmartBear Alumni (Retired)

    Hi Umair,


    If you don't want to use Aliases in your test, you can access the object by using the path as it's listed in the object tree of the tested app. For example:



    If you want to store the path to the object in the string, you can execute it by using the eval function.

  • Is this available for C# also?

    Let me be a bit more clear.  What I would like to do is something like this:

    public var GetControl (string pathTocontrol)


         return Connect.SomeMethodThatTakesAStringAndReturnsAVar(pathToControl);


    I hope that was more clear.