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

How to retrieve an ObservableCollection from a WPF UI object using Testing Framework

3 Answers 432 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 11 Oct 2019, 11:12 PM

I'm new to WPF and C#, but have been able to build a simple prototype test automation project using Telerik Testing Framework and C# in Visual Studio 2019.

The application I'm testing uses rich textfield UI objects called LookupButtons.It's a textarea object where you click a control to see a list of valid values. Using WPF Inspector, I can see all the values in an "ObservableCollection`1" object under the property CollnLookupDetails, but cannot figure out how to retrieve the ObservableCollection`1 object using Testing Framework. Is it possible to retrieve an ObservableCollection from a property?

In the attached screenshot, the application under test is on the left, with a LookupButton textarea. On the left is WPF Inspector, showing the LookupButton and its CollnLookupDetails property. There are many "LookUpDetails" objects in the collection. Those are the objects I want to get.

I may be attempting to do the wrong thing. Maybe there is a different way to get all the valid values in a WPF object collection? Any suggestions or pointers would be very much appreciated. Thank-you!

3 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 15 Oct 2019, 01:17 PM

Hello Stephen,

Thank you for contacting us with this question.

I tested against a local demo WPF application and found that it is possible to get the property of an element by its name. That said, I am not familiar with the application under test and can't provide a copy/paste example for you, please try to adjust the following code:

Applications.[application.window.element].GetProperty<ObservableCollection<object>>("ColInLookupDetails");

You need to adjust the above code example and call the method GetProperty against the correct element in the application. Furthermore, you have to specify the type of objects in the collection and get those resources by respective name.

Based on this screenshot and information, that is what I came up with. I will be happy to continue assisting your further, if you can share a sample WPF application and your iteration of this code and we can discuss it.

Thank you for your cooperation in advance.

Regards,
Plamen Mitrev
Progress Telerik

 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Stephen
Top achievements
Rank 1
answered on 17 Oct 2019, 03:14 AM

Thank-you Plamen,

It's wonderful to hear that you got it to work. I will try it out and get back to you. It's of great interest to me to be able to do this, and I spend some time on this again soon, and report back. Thanks again!

0
Plamen Mitrev
Telerik team
answered on 18 Oct 2019, 08:14 AM

Hello Stephen,

Please take your time to explore my suggestion and the Testing Framework documentation for more details.

I remain available to help you further and analyze the WPF application and the tests, that you have.

Regards,
Plamen Mitrev
Progress Telerik

 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Stephen
Top achievements
Rank 1
Answers by
Plamen Mitrev
Telerik team
Stephen
Top achievements
Rank 1
Share this question
or