Reading ObservableDictionary in DataContext

6 posts, 0 answers
  1. Hyon
    Hyon avatar
    4 posts
    Member since:
    Nov 2013

    Posted 08 Nov 2013 Link to this post

    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?
  2. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 14 Nov 2013 Link to this post

    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
  3. DevCraft banner
  4. Hyon
    Hyon avatar
    4 posts
    Member since:
    Nov 2013

    Posted 21 Nov 2013 Link to this post

    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"
  5. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 26 Nov 2013 Link to this post

    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
  6. Hyon
    Hyon avatar
    4 posts
    Member since:
    Nov 2013

    Posted 26 Nov 2013 Link to this post

    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.
  7. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 29 Nov 2013 Link to this post

    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
Back to Top
DevCraft banner