How to get the options of a dropdown list? Here are the ways to get it: Option 1: - There is a built in function in selenium getselectoptions() which can be called to get the list of options available for the select tag. For ex: string[] dropDownItems = selenium.GetSelectOptions("//select[@id='someid']"); Option 2: - If you want to get the text of the dropdown items which are in this format Option One Option Two then you can get the text for the options using: var iCount = (int) selenium.GetXpathCount("//select[@id='someid']/option"); var optionsList = new List (); for (int i = 1; i { String option = selenium.GetText("//select[@id='someid']/option[" + i + "]"); optionsList.Add(option); } Option 3: To get the id for the select options. We need the following code: var iCount = (int) selenium.GetXpathCount("//select[@id='someid']/option"); var optionsList = new List (); for (int i = 1; i { String option =...
Being in the industry for almost two decades, one thing that's been constant is change and my curiosity. I In this fast world of IT...being curious, learning and learning by doing is quintessential :) Here is my way of learning and sharing what I learnt!!! Author: Sirisha Reddy G V