I have code where I return a list of IWebElements and their corresponding names? My understanding is that a tuple with two items is basically the same thing but the Dictionary uses hash mapping to relate the two values. What is the advantage of using a Two Item Tuple over a Dictionary or vice versa?
public Dictionary<IWebElement, string> SelectAllOptions(IWebDriver driver, ref DataObject masterData)
{
//Get the ID of the dropdown menu
DatabaseRetrieval.GetObjectRepository(ref masterData);
var strDropMenuId = masterData.DictObjectRepository["ID"];
//Find the dropdown menu and pull all options into a list
try
{
var dropMenu = new SelectElement(driver.FindElement(By.Id(strDropMenuId)));
// TODO want to know how we want this list to return.
var options = dropMenu.Options as List<IWebElement>;
if (options != null)
{
var values = options.ToDictionary(option => option, option => option.Text);
return values;
}
}
Tuple<T1, T2>
is analogous toKeyValuePair<TKey, TValue>
, not a dictionary. (a dictionary contains a series of key value pairs. – Membranousoption.Text
)... – Stans