I have a simple solution to search for a string within a dropdown menu, but I would like to improve the code so it allows more options, preferable storing each option as a separate entry in a list or array which I can iterate through
I get the contents using this method and assert the string exists:
var dropdown = Driver.FindElement(element); var dropdownText = dropdown.Text; Assert.IsTrue(dropdownText.Contains("teststring"));
This method works, however the problem I have is that dropdown.text is just one long string, with each element separated by "\r\n". I have tried to store them in an IList using:
IList<string> elementTexts = Driver.FindElements(element).Select(a => a.Text).ToList();
But this gave the same results as my current method (one long string stored in a single entry in the list).
Is there a better way to perform this search or store the dropdown strings?