public static void SelectDropdownByIndex(int index) { var dropdownControl = new HtmlComboBox(browserWindow); try { dropdownControl.SearchProperties[CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType] = CSVReader.LocatorValue; dropdownControl.WaitForControlEnabled(); dropdownControl.WaitForControlReady(); } catch (Exception) { Assert.Fail("Failed to find " + CSVReader.ControlType + " Element - Element not Found"); } dropdownControl.SelectedIndex = index; }
public static void SelectDropdownByText(string text) { var dropdownControl = new HtmlComboBox(browserWindow); try { dropdownControl.SearchProperties[CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType] = CSVReader.LocatorValue; dropdownControl.WaitForControlEnabled(); dropdownControl.WaitForControlReady(); } catch (Exception) { Assert.Fail("Failed to find " + CSVReader.ControlType + " Element - Element not Found"); } if (!dropdownControl.SelectedItem.Equals(text)) { foreach (var t in dropdownControl.Items.Where(t => t.Name == text)) { dropdownControl.SelectedItem = text; break; } } }