Gets the representation of an element's shadow root for accessing the shadow DOM of a web component. A shadow root representation. Thrown when the target element is no longer valid in the document DOM. Thrown when this element does not have a shadow root.
()
| 498 | /// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception> |
| 499 | /// <exception cref="NoSuchShadowRootException">Thrown when this element does not have a shadow root.</exception> |
| 500 | public virtual ISearchContext GetShadowRoot() |
| 501 | { |
| 502 | Dictionary<string, object> parameters = new Dictionary<string, object>(); |
| 503 | parameters.Add("id", this.Id); |
| 504 | |
| 505 | Response commandResponse = this.Execute(DriverCommand.GetElementShadowRoot, parameters); |
| 506 | if (commandResponse.Value is not Dictionary<string, object?> shadowRootDictionary) |
| 507 | { |
| 508 | throw new WebDriverException("Get shadow root command succeeded, but response value does not represent a shadow root."); |
| 509 | } |
| 510 | |
| 511 | if (!ShadowRoot.TryCreate(this.driver, shadowRootDictionary, out ShadowRoot? shadowRoot)) |
| 512 | { |
| 513 | throw new WebDriverException("Get shadow root command succeeded, but response value does not have a shadow root key value."); |
| 514 | } |
| 515 | |
| 516 | return shadowRoot; |
| 517 | } |
| 518 | |
| 519 | /// <summary> |
| 520 | /// Gets the value of a CSS property of this element. |