Get class name of WPF window.

5 posts, 1 answers
  1. Evgeniy
    Evgeniy avatar
    8 posts
    Member since:
    Mar 2015

    Posted 08 Apr 2015 Link to this post

    Hello.

    I'm trying to automate one WPF application, and I need to check if my wpf window has the correct class name. How can I do that?

     Here is the part of XAML page code (I need to get class name "Namespace.View".):

     

    <WindowViewBase
        x:Class="Namespace.View"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

        <!-- some controls here -->

    </WindowViewBase>

  2. Answer
    Cody
    Admin
    Cody avatar
    3360 posts

    Posted 08 Apr 2015 Link to this post

    Hi Evgeniy,

    I'm afraid it's not possible. The class is compiled into the assembly and not put into the Visual Tree which is what Test Studio uses for automation. In addition Test Studio uses element wrappers for all UI elements making it not possible to discover what type a particular UI element is created as.

    Now having said that, what is your need to detect the class name? Maybe there's another way to accomplish your testing needs.


    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  3. Evgeniy
    Evgeniy avatar
    8 posts
    Member since:
    Mar 2015

    Posted 09 Apr 2015 in reply to Cody Link to this post

    Hello Cody.

    Thanks for your answer.

    I wanted to check if the right window opens after the click on button. The problem is that there are several windows that can open after the click, and I don't know which window will open. All this windows have the same title, but different XAML class names, that's why I wanted to check XAML class name.

  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 09 Apr 2015 Link to this post

    Hi Evgeniy,

    I would tackle this by looking for some content in the window. I assume, even though the title is the same, the content will be different. Thus if the window has X, where X is some text value or the presence of some specific UI element, then it opened the "right" window.


    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  5. Evgeniy
    Evgeniy avatar
    8 posts
    Member since:
    Mar 2015

    Posted 10 Apr 2015 in reply to Cody Link to this post

    Hello. Thanks for your advice, that is a good idea. The content of this windows is different, so I can check my window by checking several UI-controls on it.
Back to Top