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

2 posts, 0 answers
  1. Nick
    Nick avatar
    23 posts
    Member since:
    Nov 2013

    Posted 11 Mar 2014 Link to this post

    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:

    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")

    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">
        <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" />
                                  <contentpresenter Name="Content" Uid="63507614">
                                    <grid Uid="43843091">
                                      <textblock Uid="34697616">TEST</textblock>

    Am I missing something?

  2. Konstantin Petkov
    Konstantin Petkov avatar
    1911 posts

    Posted 12 Mar 2014 Link to this post


    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.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.

    Konstantin Petkov
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top