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

Reading ObservableDictionary in DataContext

5 Answers 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hyon
Top achievements
Rank 1
Hyon asked on 08 Nov 2013, 09:35 PM
Hi,

I am trying to write a Silverlight UI automation, using Telerik's testing framework.
One of the issues I have is "how to read values in ObservableDictionary in DataContext for a FrameworkElement.

When I did the following, it gives me the data binding name.
FrameworkElement f = app.find.ByName("abc");
AutomationProperty p = f.GetAutomationProperty("DataContext");
var dc = f.GetProperty(p);

How can I walk through the FrameworkElement and get the contents in DataContext?

5 Answers, 1 is accepted

Sort by
0
Velin Koychev
Telerik team
answered on 14 Nov 2013, 08:45 AM
Hello Hyon,

In order to help you best, I will need some more information about your testing scenario:
1) Could you please describe us better your testing goal and what kind of element you are testing? 
2) If it is possible grant us access to your application (or a stripped-down version) so we can reproduce the issue on our end and give you a solution.
If direct access is not possible, capture a Fiddler trace and attach it to this support ticket in a zip file. If you are unfamiliar with how to do so, this link will provide you with step-by-step instructions for download and use. If taking a Fiddler trace please be sure to:
1. Click Clear Cache first
2. Check Store binaries
3. Check Decrypt HTTPS traffic

Hope to hear from you soon.

Regards,
Velin Koychev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Hyon
Top achievements
Rank 1
answered on 21 Nov 2013, 06:26 PM
Currently I cannot share my app to the public (company restriction).

However, I attached the XAML SPY section of the object.
Simply I'd like to walk through the "DataContext\Attributes\OBJECTID"
0
Velin Koychev
Telerik team
answered on 26 Nov 2013, 01:52 PM
Hello Hyon,

Thank for the screenshot.

Unfortunately you won't be able to do the requested test scenario. it’s not possible via GetAutomationProperty. The only values you can get through that API are simple data types (strings, ints, etc.). If the requested property is some type of complex object, all you’ll get back is “object.ToString()”, which usually is the name of the object type.

Internally the code is doing a “element.[property].ToString()”. A string property simply echoes the string value. An int property is converted to a string and returned, etc. So in the end all you get is whatever “object.propert.ToString() returns.

Thank you for your understanding. 

Regards,
Velin Koychev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Hyon
Top achievements
Rank 1
answered on 26 Nov 2013, 03:44 PM
Is there any other alternative way to do this, rather than using GetAutomationProperty?
If XAML SPY can see it, I am hoping that there is a way to do this.
0
Velin Koychev
Telerik team
answered on 29 Nov 2013, 10:57 AM
Hi Hyon,

Test Studio is not able to get the properties that are behind the DataContext. Usually you can verify only the data that is located in one of the properties that are available in the Properties for element.

Thank you for your understanding.

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