I would think this would be simple. Trying to test a web page which contains a RadListBox I'm able to get it just fine. The problem appears nothing indicates what is selected in the list. I would think SelectedIndex or SelectedItem would work but both are useless.
My code:
public string GetSelectedItem(HtmlDiv parentElement, string controlID)
{
RadListBox theListbox = parentElement.Find.ById<RadListBox>(controlID);
// proof the code is getting the list box and can get a RadListBoxItem...
for( int idx = 0; idx < theListbox.ChildNodes.Count(); idx++ )
{
RadListBoxItem li = theListbox.ChildNodes[idx];
string xx = li.TextContent;
}
// only after this:
return theListbox.ChildNodes[theListbox.SelectedIndex].TextContent ;
}
And going further i would think if I'm able to get a ListBoxItem, while interating through the for loop testing if a given item has the text that i would like to set, when the time come i thought i would need to do something like:
public Boolean SetSelectedItem(HtmlDiv parentElement, string controlID)
{
RadListBox theListbox = parentElement.Find.ById<RadListBox>(controlID);
// proof the code is getting the list box and can get a RadListBoxItem...
for( int idx = 0; idx < theListbox.ChildNodes.Count(); idx++ )
{
RadListBoxItem li = theListbox.ChildNodes[idx];
if( li.TextContent.Equals( "???) )
{
li.Selected = true;
// or
theListBox.SelectedItem = li;
//
theListBox.SelectedIndex = idx;
return true;
}
return false;
}
But nothing seems to be working and the SelectedItem and SelectedIndex are both read only.
Any suggestions. This seems simple, but couldn't find any samples on here or documentation for the Art Of Test or Telerik controls which i've seen that is useful. Any suggestions are welcome.
// only after this:
return theListbox.ChildNodes[theListbox.SelectedIndex].TextContent ;
}
My code:
public string GetSelectedItem(HtmlDiv parentElement, string controlID)
{
RadListBox theListbox = parentElement.Find.ById<RadListBox>(controlID);
// proof the code is getting the list box and can get a RadListBoxItem...
for( int idx = 0; idx < theListbox.ChildNodes.Count(); idx++ )
{
RadListBoxItem li = theListbox.ChildNodes[idx];
string xx = li.TextContent;
}
// only after this:
return theListbox.ChildNodes[theListbox.SelectedIndex].TextContent ;
}
And going further i would think if I'm able to get a ListBoxItem, while interating through the for loop testing if a given item has the text that i would like to set, when the time come i thought i would need to do something like:
public Boolean SetSelectedItem(HtmlDiv parentElement, string controlID)
{
RadListBox theListbox = parentElement.Find.ById<RadListBox>(controlID);
// proof the code is getting the list box and can get a RadListBoxItem...
for( int idx = 0; idx < theListbox.ChildNodes.Count(); idx++ )
{
RadListBoxItem li = theListbox.ChildNodes[idx];
if( li.TextContent.Equals( "???) )
{
li.Selected = true;
// or
theListBox.SelectedItem = li;
//
theListBox.SelectedIndex = idx;
return true;
}
return false;
}
But nothing seems to be working and the SelectedItem and SelectedIndex are both read only.
Any suggestions. This seems simple, but couldn't find any samples on here or documentation for the Art Of Test or Telerik controls which i've seen that is useful. Any suggestions are welcome.
// only after this:
return theListbox.ChildNodes[theListbox.SelectedIndex].TextContent ;
}