Generic Find.ByAutomationId<T> method returns null whilst non-generic Find.ByAutomationId returns value

3 posts, 0 answers
  1. Artem
    Artem avatar
    4 posts
    Member since:
    Aug 2014

    Posted 19 Aug 2014 Link to this post


    I'm a little confused here: I was trying to use generic Find.ByAutomationId<T> method that is supposed to return me actually FrameworkElement object for now (the same as non-generic method returns), but it returns me null. Though when I use non-generic sibling (Find.ByAutomationId) it seems to be working fine. Any ideas why it might happen? Cast problems? I was wondering if the method actually returns anything if it can't cast, but well, non-generic works. The element is definitely present in the xaml structure and has correct automation id (as proved by non-generic method once again).

    Thank you,
  2. Artem
    Artem avatar
    4 posts
    Member since:
    Aug 2014

    Posted 21 Aug 2014 in reply to Artem Link to this post

    So, none has any ideas? the controls it looks for inherit IFrameworkElement. Non-generic works fine, but it's not suitable...
  3. Konstantin Petkov
    Konstantin Petkov avatar
    1911 posts

    Posted 22 Aug 2014 Link to this post

    Hello Artem,

    The cast could be the problem. The framework finds an element with the specified attribute, however if the cast fails it will stop the search and return null.

    Konstantin Petkov
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top