2

I have one green checkmark (an image control). I have to verify that the checkmark is green. I am not able to get the color. Can you help me?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
saran
  • 1,273
  • 4
  • 19
  • 34
  • Rather than checking the color of image. You should add the color of the image you have assigned to the color to its tag value. and then you can fetch that value to see the color of image. – Ehsan Jul 16 '13 at 04:00
  • working on coded ui.here i am not able to find image control color.I checked getcurrentstyle fuction. but not getting the color...any idea? – saran Jul 16 '13 at 04:02
  • You can do it by doing image comparison (test api core is a nice library for that) or you could get a pixel from the control an check it's color using the winapi - http://stackoverflow.com/questions/1483928/how-to-read-the-color-of-a-screen-pixel – barakcaf Jul 30 '15 at 05:48

2 Answers2

2

Coded UI is about checking the functionality of an application. It is not so good at checking the aesthetics (ie colour, size or fonts).

Rather than check the colour can you check some other feature of the UI control for the image? If the green image is not shown then what is shown instead? Try using the crosshairs tool to inspect the green image and also to inspect any other images shown in the same place. Hope to find some properties to distinguish the green image from the others.

You could request the developers to add some distinguishing features. If they do not want to then ask them how a screen reading program for sight impaired people would be able to tell the difference between the images.

For checking colours of UI controls you could capture and image of the controls and then examine the colours used in the image. To get the image use code based on

Image img = this.UIMap.UIYourApplicationsWindow.UISubWindow.UISubSub.CaptureImage();
AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
0

When testing an application with a page save message, we had an error message that was always there, but was either colored red or not to make it visible or not. I found that the filter property controldefinition had reference to the color of the control. Could you look to see if the color is mention in any of the properties? If not AdrianHHH's answer is your best bet with coded ui.

Sikuli could compare the image if you want to run a little sikuli script from your coded ui test.

yonitdm
  • 441
  • 1
  • 5
  • 10