Forum Discussion
HKosova
Alumni
15 years agoHi Jay,
Currently there's no built-in search method for list view controls in TestComplete, so your solution is the way to go. However, depending on your application under test, there may be a way faster than the plain linear search. For example:
* If the list view is working in virtual mode and data is actually stored in an external data source, say TDataSet, instead of searching for the data source, you could use its native methods (e.g. TDataSet.Lookup) and then map the found record to the list view item. (It is based on the assumption that the data source search is faster than the linear search through the list).
* If the list view is sorted by the column you're searching in, you can try a faster search algorithm, e.g. the binary search.
As for your current script, you may be able to speed it up by saving a reference to the list view control in a variable and referring to it via this variable. Also, TestComplete automatically scrolls list controls before selecting an item, so Keys('[Down]') isn't really needed (unless it's there on purpose). Here's the way I'd rewrite it:
Currently there's no built-in search method for list view controls in TestComplete, so your solution is the way to go. However, depending on your application under test, there may be a way faster than the plain linear search. For example:
* If the list view is working in virtual mode and data is actually stored in an external data source, say TDataSet, instead of searching for the data source, you could use its native methods (e.g. TDataSet.Lookup) and then map the found record to the list view item. (It is based on the assumption that the data source search is faster than the linear search through the list).
* If the list view is sorted by the column you're searching in, you can try a faster search algorithm, e.g. the binary search.
As for your current script, you may be able to speed it up by saving a reference to the list view control in a variable and referring to it via this variable. Also, TestComplete automatically scrolls list controls before selecting an item, so Keys('[Down]') isn't really needed (unless it's there on purpose). Here's the way I'd rewrite it:
lv := formSel.ListView;
for i := 0 to lv.wItemCount - 1 do begin
if (aqString.Find(lv.wItem[i, 5], TargetName, 0, False) >= 0) then begin
lv.ClickItem(i);
bSuccess := True;
break;
end;
end;