Access native properties of WPF objects

4 posts, 0 answers
  1. Sergi
    Sergi avatar
    2 posts
    Member since:
    May 2018

    Posted 24 May Link to this post

    I am starting to evaluate Test Studio for developing UI tests (entirely from Visual Studio) on a WPF application.

    One of the things I need to do is accessing the native properties of the WPF objects, namely the DataContext, or the bound Command for Buttons.

    The Test Studio tests wills reside in the same solution where the WPF App code is, so I will have access to the classes. Will I be able to do any kind of casting? If not, will I be able to access the properties in a generic way?

     

    Thank you.

  2. Nikolai
    Admin
    Nikolai avatar
    106 posts

    Posted 25 May Link to this post

    Hello Sergi,


    Thank you for reaching out to us!

    Having the app's code and the test in the same solution will not enable you to cast a TestStudio framework object to a specific WPF control type. The app under test and the test itself are quite different entities. You can use the built in wrapper objects or create your own based on the control types you have. Any control property can be accessed via the AutomationObject wrapper, please note that TestStudio framework only traverses the app's VisualTree so the DataContext property will be returned as string representation of the underlying type(Type.ToString()), same is true for the routed commands. The API does support method invocation and property setting via the framework, so it really depends on your specific needs and the property types. 

    Regards,
    Nikolai
    Progress Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  3. Sergi
    Sergi avatar
    2 posts
    Member since:
    May 2018

    Posted 01 Jun in reply to Nikolai Link to this post

    Yes, That's the behaviour I was observing (the ToString() thing).

    Thanks for your answer.

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    938 posts

    Posted 01 Jun Link to this post

    Hello Sergi,

    Thank you for getting back to us. I am glad to know the information shared by my colleague Nikolay was helpful to you. 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top