This is a migrated thread and some comments may be shown as answers.

"ComboBox contains no items" error triggered when selecting item from combobox in coded step

1 Answer 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 11 Mar 2014, 12:46 PM
I'm attempting to use a coded step to do a series of actions, including selecting an item from a silverlight radcombobox.  I can record/playback this exact scenario without any problems, but when I attempt to do the exact same thing through code I get the following error:

Error:
System.ArgumentException: ComboBox contains no items to search in and select! Please make sure the test case opens the drop down first.

Code Snippet #1 that caused error:
comboBox.SelectItem("TEST", true);  //this should both open and select the TEST item from the comobox

Code Snippet #2 attempting to workaround, the same error is triggered:
comboBox.User.Click(); //Open combobox manually
System.Threading.Thread.Sleep(5000); //Manual wait, just in case it was a speed issue
comboBox.SelectItem("TEST", false); //select the TEST item from an open combobox

Code Snippet #3 attempting to workaround, no error is triggered as the foreach is skipped because there are zero items found:
comboBox.User.Click(); //Open combobox manually
System.Threading.Thread.Sleep(5000); //Manual wait, just in case it was a speed issue
foreach (Telerik.WebAii.Controls.Xaml.RadComboBoxItem rcbi in comboBox.ItemElements) //attempting to loop through all items in combobox
{
   if (rcbi.ToString() == "TEST")
     {
         rcbi.User.Click();
     }
}

Copied from DOM:
<radcombobox Name="comboBox" AutomationId="comboBox" Uid="30481338">
  <grid Name="VisualRoot" Uid="3226344">
    <border Uid="16841414" />
    <radtogglebutton Name="PART_DropDownButton" AutomationId="PART_DropDownButton" Uid="33647865">
    </radtogglebutton>
    <validationtooltip Name="ValidationTooltip" BaseType="Control" Uid="34395333" />
    <popup Name="PART_Popup" AutomationId="PART_Popup" Uid="45097725">
      <grid Name="PopupRoot" Uid="43140557">
        <shadowchrome BaseType="Control" Uid="41122544">
        <border Name="PART_ResizeBorder" Uid="27380479">
          <grid Uid="47781518">
            <radbutton Name="PART_ClearButton" AutomationId="PART_ClearButton" Uid="34558579" />
            <scrollviewer Name="PART_ScrollViewer" AutomationId="PART_ScrollViewer" Uid="42591759">
              <border Uid="65381771">
                <grid Uid="14721181">
                  <scrollcontentpresenter Name="ScrollContentPresenter" Uid="10290070">
                    <itemspresenter Uid="51565033">
                      <stackpanel Uid="61432121">
                        <radcomboboxitem Uid="16018178">
                          <border Uid="309837">
                            <grid Uid="51795644">
                              <border Name="HighlightVisual" Uid="21433500">
                                <border Uid="58683773" />
                              </border>
                              <contentpresenter Name="Content" Uid="63507614">
                                <grid Uid="43843091">
                                  <textblock Uid="34697616">TEST</textblock>


Am I missing something?

1 Answer, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 12 Mar 2014, 09:00 AM
Hello,

I'm trying to replicate this issue but it must be something specific to the RadComboBox instance under automation since the SelectItem() method works just fine for me. I'm also looking at the recorded steps and it seems the only difference is a recorded test first executes ToggleDropDown() then SelectItem() as follows:

comboBox.ToggleDropDown();
comboBox.SelectItem("TEST", false);

If that doesn't help can you grant us access to the application with a test we can run locally to isolate the problem? Please submit a private support ticket if there is something you don't want to share publicly.

Regards,
Konstantin Petkov
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Nick
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Share this question
or