Forum Discussion
- anna_v
Staff
Hi Mustak
Check boxes in your list box are not individual controls. They are the part of list box items, and selecting a check box actually means selecting a certain item. That is, the wSelected property is the one you need.
Ann
- mustak_mOccasional ContributorThanks for the reply. I tried wSelected property, but it returns true if item is selected(i.e., focused) wether it is checked or unchecked. I want to know the state of the checkbox.
Thanks,
Mustak - spatel_1Occasional ContributorHi Mustak,
If wChecked is unavailable, you can use some native methods to acquire the same information. The method you need is FindItemWithText.
var list = your list view;
var item = list["FindItemWithText"]("MyItemText");
if(item["Checked"])
Log["Event"]("MyItemText was checked.");
else
Log["Error"]("MyItemText was not checked!");
If you don't have the FindItemWithText method, but you do have the Items Property, you can do the same thing with a little extra work.
function findItemByText(list, itemText){
var count = list["Items"]["Count"];
for(var i = 0; i < count; i++){
var item = list["Items"]["Item"](0);
if(item["Text"] == itemText){
Log["Event"]("Item with text "+itemText+" was found.");
return item;
}
}
Log["Error"]("Item with text "+itemText+" does not exist in this ListView!");
return null;
}
Then you can use the same basic procedure:
var list = your list view;
var item = findItemByText(list, "MyItemText");
if(item["Checked"])
Log["Event"]("MyItemText was checked.");
else
Log["Error"]("MyItemText was not checked!");
Stephen - anna_v
Staff
Hi,
Standard implementation of a list box control of a ListBox class does not include check boxes. That is why, TestComplete does not provide support for this functionality. You can try to inspect native properties and methods of your list box control as Stephen suggested.
Ann
- mustak_mOccasional Contributor
Stephen/Ann,
I tried to implement your suggestions but no success.
1. "ItemWithText" method is not available.
2. Not able to retrieve the required item as "list["Items"]["Item"](0)" not supported.
3. We can get the count using property - wItemCount and using wItem returns the name of the item specified by its index. Not sure how to retrieve the required item.
4. Test complete is using coordinates, when i performed actions on checkbox.
Ex. listBox.ClickItemXY(2,5,4)I have attached screen shot of properties available for this object.
All inputs are welcome.
Thanks,
Mustak - anna_v
Staff
Hi,
TestComplete does not provide control-specific methods for your functionality. You can compile your application with debug information and inspect native properties and methods to find any of them that are appropriate for your needs. Please refer to the help system and go through the "Testing Visual C++ applications" section to learn how to prepare and test Visual C++ applications.
As for support for your particular control, we have a corresponding suggestion in our DB, and your message has increased its rating.
Thanks.
Ann