how to select the item in combo/dropdown by text not by index

Jul 3, 2012 at 6:07 PM

Hi ,

In your sample code, I see "SelectItemBytext". However, I don't see this property/method for my dropdown list. How to set the item value by text, not by index ? Appreciate your help.

[TestMethod]
        public void Telerik_Combo()
        {
            ASPNETComboBoxDemoFirstLook pgPage = CUITe_BrowserWindow.Launch<ASPNETComboBoxDemoFirstLook>(
                "http://demos.telerik.com/aspnet-ajax/combobox/examples/default/defaultcs.aspx");
            Thread.Sleep(5000);
            pgPage.Refresh();
            Thread.Sleep(5000);
            pgPage.combo1.SelectItemByText("Tofu", 5000);
            pgPage.combo2.SelectItemByText("Bloomfield Hills", 5000);
            pgPage.combo3.SelectItemByText("Exotic Liquids", 5000);
            pgPage.combo4.SelectItemByText("American Express", 5000);
            pgPage.Close();
        }

 

Thanks,

Sailaja

Coordinator
Jul 3, 2012 at 6:31 PM

Hi Sailaja,

That sample code is for the Teleirk html combobox control (i.e. Telerik_ComboBox).

For a standard html combobox, see this discussion: http://cuite.codeplex.com/discussions/361428

From TestHtmlPage.html:

<select id="select1">
    <option>Cricket</option>
    <option>Football</option>
    <option>Tennis</option>
</select>

From Tests_for_HtmlControls.cs:

CUITe_BrowserWindow bWin = CUITe_BrowserWindow.Launch(CurrentDirectory + "/TestHtmlPage.html", "A Test");
var cmb = bWin.Get<CUITe_HtmlComboBox>("Id=select1");
Assert.AreEqual("Football", cmb.Items[1]);
Assert.IsTrue(cmb.ItemExists("Cricket"));
bWin.Close();

 

The SelectItem method of CUITe_HtmlComboBox can be used to select an item.

Jul 13, 2012 at 6:02 PM

Thank you for your response.

I have combo box for list counties. I asked to select "United States",but the combo is selecting "U.S. Minor Outlying Islands" . What could be the reason ? 

Here is my code:

pgSubmitServiceOrder.cboSelectedCountry.SelectItem(htSubmitServiceOrderData["country"].ToString());

<

country>United States</country

>

 

Thanks,

Sailaja

 

 

 

Coordinator
Jul 14, 2012 at 3:12 AM

I could not reproduce this issue.

Please make sure htSubmitServiceOrderData["country"].ToString() actually equals "United States".

Otherwise, please provide the minimum definitions of pgSubmitServiceOrder, cboSelectedCountry, htSubmitServiceOrderData, the html page, and xml file that can reproduce the issue.