Forum Discussion

abinash11's avatar
abinash11
Occasional Contributor
5 years ago
Solved

Checking WPF style in TestComplete

We have a GUI based desktop application built using WPF.

 

There are requirements to check the colour change of the GUI controls when they are clicked.

 

However, the application uses WPF styles and apply the different styles when some controls are clicked/toggled etc.

When I use Object spy in TestComplete, the background and foreground properties do not reflect the real colours displayed and this is most probably due to the styles being applied instead of setting the colour changes directly using the background and foreground properties.

 

Does someone know a way to Identify these WPF style changes using TestComplete ?

6 Replies

  • Hi,

     

    I would talk to developers and ask them how the applied style translates to the color. My expectation is that they will be able to name some native control's property that you will be able to read from test code.

     

    • abinash11's avatar
      abinash11
      Occasional Contributor

      Yes, there is a property that applies the Style.

      But the requirement is explicitly mentioning the colour change into Red or Blue. So, If there is a bug on using the property in the application code, TestComplete will still "Pass" the test case if we stick to using only the property for testing the Style.

       

      I am surprised that this is not already handled in someway by TestComplete. Retrieving the style name at least will be a good start. 

      • AlexKaras's avatar
        AlexKaras
        Icon for Champion Level 3 rankChampion Level 3

        Hi,

         

        I meant not the property with the name of the style, but the property that indicates the current color of the given element (text, background, border, etc.). If such property is exposed (i.e. is of public or published type) then TestComplete should be able to access it. Otherwise ask your developers for the method that returns color for the specified element of the control.

         

        P.S. If there is a property that contains the name of the applied style, then you may consider slightly different approach: get the name of the applied style and for this style get the value of the required element (foreground/background color, etc.) and check that it is of required value (red, green, ...).