public void Invoke(LocatedElements elements, OptionLocator optionLocator) { var action = new OpenQA.Selenium.Interactions.Actions(Context.Driver); elements .ConstraintCount(c => c == 1) .Elements .ForEach(x => PerformSelection(new SelectElement(x), optionLocator)); }
private void PerformSelection(SelectElement selectElement, OptionLocator optionLocator) { var locators = new Dictionary <string, Action <SelectElement, string> >() { { "index", (e, v) => e.DeselectByIndex(int.Parse(v)) }, { "label", (e, v) => e.DeselectByText(v) }, { "value", (e, v) => e.DeselectByValue(v) } }; foreach (var locator in locators) { if (optionLocator.Type.Equals(locator.Key, StringComparison.InvariantCultureIgnoreCase)) { locator.Value(selectElement, optionLocator.Value); return; } } throw new OptionNotFoundException(optionLocator); }
public OptionNotFoundException(OptionLocator locator) : base($"An option that would satisfy the locator ({locator.Locator}) was not found") { }