MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / DeselectByIndex

Method DeselectByIndex

dotnet/src/support/UI/SelectElement.cs:346–364  ·  view source on GitHub ↗

Deselect the option by the index, as determined by the "index" attribute of the element. Thrown when attempting to deselect option from a SELECT that does not support multiple selections. Thrown when no element exists with the specified index attribute. <param name="ind

(int index)

Source from the content-addressed store, hash-verified

344 /// <exception cref="NoSuchElementException">Thrown when no element exists with the specified index attribute.</exception>
345 /// <param name="index">The value of the index attribute of the option to deselect.</param>
346 public void DeselectByIndex(int index)
347 {
348 if (!this.IsMultiple)
349 {
350 throw new InvalidOperationException("You may only deselect option if multi-select is supported");
351 }
352
353 string match = index.ToString(CultureInfo.InvariantCulture);
354 foreach (IWebElement option in this.Options)
355 {
356 if (match == option.GetAttribute("index"))
357 {
358 SetSelected(option, false);
359 return;
360 }
361 }
362
363 throw new NoSuchElementException("Cannot locate option with index: " + index);
364 }
365
366 private static string EscapeQuotes(string toEscape)
367 {

Calls 2

ToStringMethod · 0.45
GetAttributeMethod · 0.45