How to locate elements without specifying the Object Type

3 posts, 0 answers
  1. Ss
    Ss avatar
    2 posts
    Member since:
    Jan 2013

    Posted 10 Jan 2013 Link to this post

    Hi All,

    I want to locate the elements without specifying the Object Type.
    Below is my code:

    Dim Element = wpfApp.Find.AllByName("UserName")
    'Above line I am getting the issue.

    If I use the below code then its working.
    Dim Element = wpfApp.Find.AllByName(of TextBox)("UserName")

    But I want to locate the objects without specifying object type or else in the way of below code

    Dim ObjType = "TextBox"
    Dim Element = wpfApp.Find.AllByName(of ObjType)("UserName")
  2. Ss
    Ss avatar
    2 posts
    Member since:
    Jan 2013

    Posted 11 Jan 2013 Link to this post

    Hi Guys,

    Till now no reply from any one.. Plz help in me to get rid of locating the elements with out specifying the object type.

    Regards,
    Ss
  3. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 15 Jan 2013 Link to this post

    Hello Ss,

    I apologize it took us so long to get back to you. We're temporarily overloaded in support and trying to catch up as quickly as we can.

    The first thing to keep in mind is that all the UI elements you can find in a WPF application derive from the base class FrameworkElement.  All of the Find.AllByxxx methods return an IList i.e. an array of objects. You can store them into a generic list of FrameworkElement objects like this:

    Dim elements As IList(Of FrameworkElement) = wpfApp.MainWindow.Find.AllByName("UserName")

    Or get a single element of any type like this:

    Dim userElement As FrameworkElement = wpfApp.MainWindow.Find.ByName("UserName")

    I hope this helps.

    Kind regards,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top