diff --git a/website_and_docs/content/documentation/webdriver/elements/finders.en.md b/website_and_docs/content/documentation/webdriver/elements/finders.en.md index 533e13eab3a9..d3e72962f547 100644 --- a/website_and_docs/content/documentation/webdriver/elements/finders.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/finders.en.md @@ -108,6 +108,40 @@ driver implementation supports a given feature. These interfaces are clearly def to adhere to having only a single role of responsibility. {{% /pageinfo %}} +### Evaluating the Shadow DOM + +The Shadow DOM is an encapsulated DOM tree hidden inside an element. +With the release of v96 in Chromium Browsers, Selenium can now allow you to access this tree with +easy-to-use shadow root methods. NOTE: These methods require Selenium 4.0 or greater. + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} +{{< tab header="Java" >}} +WebElement shadowHost = driver.findElement(By.cssSelector("#shadow_host")); +SearchContext shadowRoot = shadowHost.getShadowRoot(); +WebElement shadowContent = shadowRoot.findElement(By.cssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Python" >}} +shadow_host = driver.find_element(By.CSS_SELECTOR, '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(By.CSS_SELECTOR, '#shadow_content') +{{< /tab >}} +{{< tab header="CSharp" >}} +var shadowHost = _driver.FindElement(By.CssSelector("#shadow_host")); +var shadowRoot = shadowHost.GetShadowRoot(); +var shadowContent = shadowRoot.FindElement(By.CssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Ruby" text=true >}} +shadow_host = @driver.find_element(css: '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(css: '#shadow_content') +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} + ### Optimized locator A nested lookup might not be the most effective location strategy since it requires two diff --git a/website_and_docs/content/documentation/webdriver/elements/finders.ja.md b/website_and_docs/content/documentation/webdriver/elements/finders.ja.md index 47c4adac366d..1b1b676b9577 100644 --- a/website_and_docs/content/documentation/webdriver/elements/finders.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/finders.ja.md @@ -101,6 +101,40 @@ val fruit = fruits.findElement(By.className("tomatoes")) これらのインターフェースは明確に定義されており、責任の役割を1つだけ持つように努めています。 {{% /pageinfo %}} +### Evaluating the Shadow DOM + +The Shadow DOM is an encapsulated DOM tree hidden inside an element. +With the release of v96 in Chromium Browsers, Selenium can now allow you to access this tree +with easy-to-use shadow root methods. NOTE: These methods require Selenium 4.0 or greater. + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} +{{< tab header="Java" >}} +WebElement shadowHost = driver.findElement(By.cssSelector("#shadow_host")); +SearchContext shadowRoot = shadowHost.getShadowRoot(); +WebElement shadowContent = shadowRoot.findElement(By.cssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Python" >}} +shadow_host = driver.find_element(By.CSS_SELECTOR, '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(By.CSS_SELECTOR, '#shadow_content') +{{< /tab >}} +{{< tab header="CSharp" >}} +var shadowHost = _driver.FindElement(By.CssSelector("#shadow_host")); +var shadowRoot = shadowHost.GetShadowRoot(); +var shadowContent = shadowRoot.FindElement(By.CssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Ruby" text=true >}} +shadow_host = @driver.find_element(css: '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(css: '#shadow_content') +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} + ### 最適化されたロケーター ネストされたルックアップは、ブラウザに2つの別々のコマンドを発行する必要があるため、最も効果的なロケーション戦略ではない可能性があります。 diff --git a/website_and_docs/content/documentation/webdriver/elements/finders.pt-br.md b/website_and_docs/content/documentation/webdriver/elements/finders.pt-br.md index 89e20a5414f0..194dab752908 100644 --- a/website_and_docs/content/documentation/webdriver/elements/finders.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/elements/finders.pt-br.md @@ -104,6 +104,40 @@ implementação de driver suporta um recurso específico. Essas interfaces são aderir a ter apenas um único papel de responsabilidade. {{% /pageinfo %}} +### Evaluating the Shadow DOM + +The Shadow DOM is an encapsulated DOM tree hidden inside an element. +With the release of v96 in Chromium Browsers, Selenium can now allow you to access this tree +with easy-to-use shadow root methods. NOTE: These methods require Selenium 4.0 or greater. + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} +{{< tab header="Java" >}} +WebElement shadowHost = driver.findElement(By.cssSelector("#shadow_host")); +SearchContext shadowRoot = shadowHost.getShadowRoot(); +WebElement shadowContent = shadowRoot.findElement(By.cssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Python" >}} +shadow_host = driver.find_element(By.CSS_SELECTOR, '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(By.CSS_SELECTOR, '#shadow_content') +{{< /tab >}} +{{< tab header="CSharp" >}} +var shadowHost = _driver.FindElement(By.CssSelector("#shadow_host")); +var shadowRoot = shadowHost.GetShadowRoot(); +var shadowContent = shadowRoot.FindElement(By.CssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Ruby" text=true >}} +shadow_host = @driver.find_element(css: '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(css: '#shadow_content') +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} + ### Localizador otimizado Uma pesquisa aninhada pode não ser a estratégia de localização mais eficaz, pois requer dois comandos separados a serem emitidos para o navegador. diff --git a/website_and_docs/content/documentation/webdriver/elements/finders.zh-cn.md b/website_and_docs/content/documentation/webdriver/elements/finders.zh-cn.md index 372a13880ed4..316d346f5b95 100644 --- a/website_and_docs/content/documentation/webdriver/elements/finders.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/elements/finders.zh-cn.md @@ -107,6 +107,40 @@ driver implementation supports a given feature. These interfaces are clearly def to adhere to having only a single role of responsibility. {{% /pageinfo %}} +### Evaluating the Shadow DOM + +The Shadow DOM is an encapsulated DOM tree hidden inside an element. +With the release of v96 in Chromium Browsers, Selenium can now allow you to access this tree +with easy-to-use shadow root methods. NOTE: These methods require Selenium 4.0 or greater. + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} +{{< tab header="Java" >}} +WebElement shadowHost = driver.findElement(By.cssSelector("#shadow_host")); +SearchContext shadowRoot = shadowHost.getShadowRoot(); +WebElement shadowContent = shadowRoot.findElement(By.cssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Python" >}} +shadow_host = driver.find_element(By.CSS_SELECTOR, '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(By.CSS_SELECTOR, '#shadow_content') +{{< /tab >}} +{{< tab header="CSharp" >}} +var shadowHost = _driver.FindElement(By.CssSelector("#shadow_host")); +var shadowRoot = shadowHost.GetShadowRoot(); +var shadowContent = shadowRoot.FindElement(By.CssSelector("#shadow_content")); +{{< /tab >}} +{{< tab header="Ruby" text=true >}} +shadow_host = @driver.find_element(css: '#shadow_host') +shadow_root = shadow_host.shadow_root +shadow_content = shadow_root.find_element(css: '#shadow_content') +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} + ### Optimized locator A nested lookup might not be the most effective location strategy since it requires two