This is a migrated thread and some comments may be shown as answers.

How to locate elements without specifying the Object Type

2 Answers 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ss
Top achievements
Rank 1
Ss asked on 10 Jan 2013, 03:15 PM
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 Answers, 1 is accepted

Sort by
0
Ss
Top achievements
Rank 1
answered on 11 Jan 2013, 11:27 AM
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
0
Cody
Telerik team
answered on 15 Jan 2013, 10:35 PM
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
Tags
General Discussions
Asked by
Ss
Top achievements
Rank 1
Answers by
Ss
Top achievements
Rank 1
Cody
Telerik team
Share this question
or