Verifying that drop-down list contains text

6 posts, 0 answers
  1. Helen
    Helen avatar
    15 posts
    Member since:
    Sep 2010

    Posted 29 Sep 2010 Link to this post

    Hi

    I need to verify that the drop-down list(combobox) contains specific text.
    I have no idea how to do it using the regular verification tools.

    Is it possible at all, and if yes - how?

    Thanks a lot in advance
    Helen
  2. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 01 Oct 2010 Link to this post

    Hi Helen,

    Do you mean you need to check if the combobox contains an item with specific text or if the text of the combobox (the item you already picked) matches some value? Also we need to know the exact component you're automating. Is that RadComboBox or MS one? Is that ASP.NET or Silverlight ComboBox?

    Greetings,
    Konstantin Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Helen
    Helen avatar
    15 posts
    Member since:
    Sep 2010

    Posted 01 Oct 2010 Link to this post

    Hi Konstantin,

    I need to check if combobox contains an item with specific text.

    And the combobox is Silverlight combobox and is recognized as IcUserTypesCombobox(if this is of any help).

    Please let me know if I answered your question

    Spasibo!
    Helen
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 01 Oct 2010 Link to this post

    Hi Helen,

    This sort of verification must be done using a coded step. In the coded step you must follow these steps:

    Fetch the list of items contained in the combobox
    Scan through the list looking for a string match on the item

    The code will look like this:

    string textToFind = "String Item";
    bool found = false;
     
    ComboBox cb = Pages.ComboBoxItemSilverlight.FrameContent.SilverlightApp.MyComboCombobox;
     
    foreach (ComboBoxItem item in cb.Items)
    {
        if (item.Content.ToString().Equals(textToFind))
        {
            found = true;
            break;
        }
    }
    Assert.IsTrue(found);

    Also due to the nature of how Silverlight works, you must open the combobox just once before you will get the list of items attached to it. Silverlight doesn't actually add the items to the combobox until it actually needs to display them.

    I've attached a sample test against the MSDN Silverlight control demo page that demonstrates verifying the combobox contains a certain text item.

    Kind regards,
    Cody

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Austin
    Austin avatar
    17 posts
    Member since:
    Sep 2015

    Posted 11 Oct 2018 Link to this post

    Hi,

    I want to verify elements of dropdown list contains specific text

    for this i am identifying drop down element via xpath in coded step.

    Element dropDown = Find.Byxpath("//input[@id='dropDown_select_locator']")

    What is the coded step to fetch all ts list elements and save it in list.

    I want to fetch all dropdown list options and save it in iList.

     

  6. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    992 posts

    Posted 23 Oct 2018 Link to this post

    Hello Austin,

    Based on the shared details I assume that toggling the dropdown triggers the appearance of the list with items in the DOM tree. Probably this is a HTMLUnorderedList which items can be easily accessed and used in a foreach cycle. The foreach statement should be built similarly to the example how to iterate through each grid cell.

    Please keep in mind that if the list appears dynamically in the DOM tree, you will need to refresh that in the code as well. That way you will ensure that the Testing Framework has its latest state. 

    Manager.ActiveBrowser.RefreshDomTree();

    I hope the above helps. Still, if it doesn't. or the information is insufficient to find the proper solution, please prepare a sample test against an accessible page to demonstrate what difficulties you are facing. 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top