Select the option by the index, as determined by the "index" attribute of the element. The value of the index attribute of the option to be selected. Thrown when no element exists with the specified index attribute.
(int index)
| 231 | /// <param name="index">The value of the index attribute of the option to be selected.</param> |
| 232 | /// <exception cref="NoSuchElementException">Thrown when no element exists with the specified index attribute.</exception> |
| 233 | public void SelectByIndex(int index) |
| 234 | { |
| 235 | string match = index.ToString(CultureInfo.InvariantCulture); |
| 236 | |
| 237 | foreach (IWebElement option in this.Options) |
| 238 | { |
| 239 | if (option.GetAttribute("index") == match) |
| 240 | { |
| 241 | SetSelected(option, true); |
| 242 | return; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | throw new NoSuchElementException("Cannot locate option with index: " + index); |
| 247 | } |
| 248 | |
| 249 | /// <summary> |
| 250 | /// Clear all selected entries. This is only valid when the SELECT supports multiple selections. |