-
-
Save admariner/17e7463dc1f8854112c115c443864092 to your computer and use it in GitHub Desktop.
Handle shadow-DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package shadowDom; | |
import java.util.concurrent.TimeUnit; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
/** | |
* | |
* @author Koushik Chatterjee | |
* | |
*/ | |
public class ChromeShadow { | |
static ChromeDriver driver; | |
public static void main(String[] args) { | |
driver = new ChromeDriver(); | |
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); | |
driver.get("http://chrisbateman.github.io/guide-to-web-components/demos/shadow-dom.htm"); | |
String shadowElement = "return document.querySelector(\"#demo1\").shadowRoot.querySelector(\"p:nth-child(2)\").textContent"; | |
String text = driver.executeScript(shadowElement).toString(); | |
System.out.println("Shadow element text is: " + text); | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment