ComboBox

Apr 4, 2014 at 5:54 PM
Edited Apr 4, 2014 at 6:05 PM
Hello,

I have a small HTML page like this:
<!DOCTYPE>
<html>
<head>
  <title>ComboBox</title>
</head>

<body>
  <div id="divOuter">
    <select id="selDateRange" style="width: 135px; height: 56px; text-transform: none;" size="5">
      <option value="Today">Today
      </option>
      <option value="Tomorrow">Tomorrow
      </option>
      <option value="Yesterday">Yesterday
      </option>
    </select>
  </div>
</body>
</html>
When I am doing something like this:
public new string sWindowTitle = "ComboBox";
public CUITe_HtmlComboBox comboBox = new CUITe_HtmlComboBox("Id=selDateRange");
comboBox.SelectItem(1);
I get the following error:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details: 
TechnologyName:  'Web'
ControlType:  'ComboBox'
TagName:  'SELECT'
Id:  'seldaterange'
 Failed to find any control that matched the search condition Id='seldaterange' && ControlType='ComboBox' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
This should've worked. Can someone please help me with this?

Thanks,
Kay
Apr 7, 2014 at 2:58 PM
Shouldn't that be SelectedIndex instead of SelectItem?

Other than that, I am not really sure why it isn't working for you
Apr 8, 2014 at 10:56 PM
My version of CUITe shows SelectedIndex as a property, not a method.
Apr 9, 2014 at 4:54 PM
You are right, I should try these out before posting!

Looking at your code, you might not be looking in the context of the page (just a guess).

Something like this should work
           public new string sWindowTitle = "ComboBox";
            CUITe_BrowserWindow test = CUITe_BrowserWindow.Locate(sWindowTitle);

            CUITe_HtmlComboBox comboBox= test.Get<CUITe_HtmlComboBox>("Id=selDateRange");
            comboBox.SelectItem(1);