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

Method GetShadowRoot

dotnet/src/webdriver/WebElement.cs:500–517  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

ExecuteMethod · 0.95
TryCreateMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected