I briefly looked over the documentation for .NET and the sample for SharpDevelop.
I see that you can find form controls by name, etc. But can you read or get the default value or the list of values in a form control like a textbox, listbox, etc.?
And can you set the value of a form control like set a listbox to one of its prefined values in list (after reading the list of values) instead of sending up/down arrow keystrokes to select it in a manual GUI-wise fashion.
It would be nice if there are such features. If they exist already, can someone provide examples? Thanks.
Read/get and set value of a form control?
1. Control classes
You can use the functions of the ListBox or TreeViw class for automating the standard controls.
See the RanorexVS2005Sample2 sample for more details.
You can read and select all items in a ListBox as follows:
2. Element class
The Ranorex element approach supports a general way to access every kind of control and control elements. It should also work with custom controls.
The following code reads all items from a listbox:
(This code works in V1.2.0-Beta2 or above)
The following code reads all items from a listbox beginning with "List":
See the RanorexVS2005Sample3 sample for more details.
Jenö
Ranorex Team
You can use the functions of the ListBox or TreeViw class for automating the standard controls.
See the RanorexVS2005Sample2 sample for more details.
You can read and select all items in a ListBox as follows:
Code: Select all
itemCount = listBox.ItemCount;
for (int i=0; i < itemCount;i++)
{
text = listBox.GetItemText(i);
Console.WriteLine(" Item[{0}]={1}",i,text);
listBox.SelectedText = text;
}
The Ranorex element approach supports a general way to access every kind of control and control elements. It should also work with custom controls.
The following code reads all items from a listbox:
(This code works in V1.2.0-Beta2 or above)
Code: Select all
Element[] listItems = listView.Element.FindChildren(Role.ListItem, null, null, SearchMatchMode.MatchExact);
foreach (Element listItem in listItems)
{
Console.WriteLine("Item={0})", listItem.Name);
}
Code: Select all
Element[] listItems1 = listView.Element.FindChildren(Role.ListItem,
"List", null, SearchMatchMode.MatchFromStart);
foreach (Element listItem in listItems1)
{
Console.WriteLine("Item={0})", listItem.Name);
}
Jenö
Ranorex Team