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

Verifying that drop-down list contains text

5 Answers 159 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Helen
Top achievements
Rank 1
Helen asked on 29 Sep 2010, 09:58 PM
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

5 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 01 Oct 2010, 08:49 AM
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
0
Helen
Top achievements
Rank 1
answered on 01 Oct 2010, 05:02 PM
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
0
Cody
Telerik team
answered on 02 Oct 2010, 12:06 AM
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
0
Austin
Top achievements
Rank 1
answered on 11 Oct 2018, 12:40 PM

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.

 

0
Elena
Telerik team
answered on 23 Oct 2018, 08:27 AM
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
 
Tags
General Discussions
Asked by
Helen
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Helen
Top achievements
Rank 1
Cody
Telerik team
Austin
Top achievements
Rank 1
Elena
Telerik team
Share this question
or