Deselect the option having value matching the specified text. Thrown when attempting to deselect option from a SELECT that does not support multiple selections. Thrown when no element exists with the specified value attribute. The value of the option
(string value)
| 313 | /// </para> |
| 314 | /// </remarks> |
| 315 | public void DeselectByValue(string value) |
| 316 | { |
| 317 | if (!this.IsMultiple) |
| 318 | { |
| 319 | throw new InvalidOperationException("You may only deselect option if multi-select is supported"); |
| 320 | } |
| 321 | |
| 322 | bool matched = false; |
| 323 | StringBuilder builder = new StringBuilder(".//option[@value = "); |
| 324 | builder.Append(EscapeQuotes(value)); |
| 325 | builder.Append("]"); |
| 326 | IList<IWebElement> options = this.WrappedElement.FindElements(By.XPath(builder.ToString())); |
| 327 | foreach (IWebElement option in options) |
| 328 | { |
| 329 | SetSelected(option, false); |
| 330 | matched = true; |
| 331 | } |
| 332 | |
| 333 | if (!matched) |
| 334 | { |
| 335 | throw new NoSuchElementException("Cannot locate option with value: " + value); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /// <summary> |
| 340 | /// Deselect the option by the index, as determined by the "index" attribute of the element. |