While testing list box controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.
When testing a list box control, you may need to know the total number of items that the control contains. The Win32ListBox
object provides a number of properties, which let you work with standard Windows list box controls. To determine the total number of list box’s items, you can use the wItemCount
property, which belongs to the Win32ListBox
object.
The following code snippet posts the total number of items to the log:
JavaScript, JScript
function Main()
{
var p, w, ListBox;
// Obtain list box object
p = Sys.Process("wordpad");
Sys.Keys("~i[Enter]");
w = p.Window("#32770", "Date and Time");
ListBox = w.Window("ListBox", "", 1);
// Post total number of items to the log
Log.Message("Number of items: " + ListBox.wItemCount);
}
Python
def Main():
# Obtain list box object
p = Sys.Process("wordpad")
Sys.Keys("~i[Enter]")
w = p.Window("#32770", "Date and Time")
ListBox = w.Window("ListBox", "", 1)
# Post total number of items to the log
Log.Message("Number of items: " + ListBox.wItemCount)
VBScript
Sub Main
Dim p, w, ListBox
' Obtain list box object
Set p = Sys.Process("wordpad")
Sys.Keys "~i[Enter]"
Set w = p.Window("#32770", "Date and Time")
Set ListBox = w.Window("ListBox", "", 1)
' Post total number of items to the log
Log.Message("Number of items: " & ListBox.wItemCount)
End Sub
DelphiScript
procedure Main;
var p, w, ListBox : OleVariant;
begin
// Obtain list box object
p := Sys.Process('wordpad');
Sys.Keys('~i[Enter]');
w := p.Window('#32770', 'Date and Time', 1);
ListBox := w.Window('ListBox', '', 1);
// Post total number of items to the log
Log.Message('Number of items: ' + aqConvert.VarToStr(ListBox.wItemCount));
end;
C++Script, C#Script
function Main()
{
var p, w, ListBox;
// Obtain list box object
p = Sys["Process"]("wordpad");
Sys.Keys("~i[Enter]");
w = p["Window"]("#32770", "Date and Time", 1);
ListBox = w["Window"]("ListBox", "", 1);
// Post total number of items to the log
Log.Message("Number of items: " + ListBox.wItemCount);
}
See Also
Working With List Box Controls
wItemCount Property (ListBox Controls)