asavoia
5 years agoOccasional 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...
- 5 years ago
Use pixel property of the picture of the object
https://support.smartbear.com/testcomplete/docs/reference/program-objects/picture/pixels.html
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; break; } if (found) break; } } } catch(e) { qa.system.logExceptionByLevel(e, 'isCheckedTCheckListBox()', null, 'Warning'); } return found; };
- 5 years ago
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.