Ask a Question

background color

Occasional Contributor

background color

Hi everyone
I have a problem with the backgroud color of an object, I can't understand how to detect it. Using the object spy on the object, there is no property that tells me the color. Do you have any suggestions?

thank you very much

Community Hero

Use pixel property of the picture of the object


Example of use:

  qa.system.isCheckedTCheckListBox (OBJECT CheckListBox, INTEGER Item, INTEGER CheckColor)
    Check state of a TCheckListBox item (must be visible)
    CheckListBox is the TCheckListBox object to check
    Item is the line number to check
    CheckColor is the color code of checkbox. Default value is clBlack
    Return true if item is checked
  qa.system.isCheckedTCheckListBox = function (CheckListBox, Item, CheckColor = clBlack) {
    var found = false;
    try {
      var image = CheckListBox.Picture(CheckListBox.wItemBounds(Item).Left + 4, CheckListBox.wItemBounds(Item).Top + 7, 8, 8, false);
      for (var i = 0;i<8;i++) {
        for (var j = 0;j<8;j++) {
          if (image.Pixels(i, j) == CheckColor) {
            found = true;
          if (found)
    catch(e) {
      qa.system.logExceptionByLevel(e, 'isCheckedTCheckListBox()', null, 'Warning');
    return found;


Un sourire et ça repart

I was just wondering how to write something like that! I have to test it!


Do you have any idea how to define a color if I see no value in ObjectSpy?


A color is not saved as an object property.



To know the color on screen use a good screen capture software (like ShareX which has built-in on-screen color reader).

Or do a reverse like using a loop from the picture of the object and logging the pixel value (wich is the color value).

Un sourire et ça repart

Esteemed Contributor

Is this a web app or desktop app?  If a web app, you might be able to get the color from the CSS on the object.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

This is a desktop application.


The problem is even more unusual because it's about background verifications on the site with which the only interaction for me is searching for content using:

Using Text Recognition Technology


I'm looking for a single value on the fence ->
I'm looking for TextObject("") ->
and now how do you get a background here?


I can artificially use the above function by wandering left and right coordination.


SmartBear Alumni (Retired)

Hi Guys,

I like BenoitB's approach. @Wamboo, are you working with @asavoia?

If you use the TextObject method to get the needed text, I think it should be possible to treat the obtained rectangle as an image. After that, you can calculate the background color as the most common pixel color in the object or the first 2 px from top and from left (depending on what you TextObject will return.

Tanya Yatskovskaya
SmartBear Community and Education Manager



No, I don't work with asavoia.


Tanya your solution is a very good idea. I definitely need to test it.


Thank you all for your help.

Showing results for 
Search instead for 
Did you mean: