If you want to find the selected radioItem use the Element.State Property like shown below….
Code: click into code to enlarge
static public void DumpElementTree(Element element, int level)
{
level++;
int childCount = element.GetChildCount;
for (int index = 0; index < childCount; index++)
{
Element child = element.GetChild(index);
if ((child.State & State.Selected) != 0)
Console.WriteLine("selected = " + child.Name);
DumpElementTree(child, level);
}
}
[STAThread]
static int Main(string[] args)
{
...
Control radioGroup = form.FindControlName("radioGroupSample");
if (radioGroup == null)
{
Console.WriteLine("Cannot find radioGroup ");
return 1;
}
DumpElementTree(radioGroup.Element, 0);
...
}
In the next version you can use the findChildren method to find elements more easier(RegularExpression …):
Code: click into code to enlarge
Element[] radioItems = radioGroup.Element.FindChildren(Role.ListItem, null, null, SearchMatchMode.MatchExact);
foreach (Element item in radioItems)
{
if ((item.State & State.Selected) != 0)
Console.WriteLine("selected = " + item.Name);
}
Gabor
Ranorex Team |