Unable to select a shadow root element that is present under a dropdown using selenium Java.
Tried with JS path, but the id keeps changing dynamically, so unable to select it.
document.querySelector("#eds-select").shadowRoot.querySelector("someID > span")
Text is available.
If there is a way to select the dropdown through text, please let me know.
Tried with the below solution, but getting class cast exception with WebdriverWrapper and RemoteWebElement.
Map<String, Object> shadowRootMap = (Map<String, Object>) shadowRoot;
String shadowRootKey = (String) shadowRootMap.keySet().toArray()[0];
String id = (String) shadowRootMap.get(shadowRootKey);
RemoteWebElement remoteWebElement = new RemoteWebElement();
remoteWebElement.setParent((RemoteWebDriver) driver);
remoteWebElement.setId(id);
returnObj = remoteWebElement;
Tried with the below solution, but getting class cast exception with WebdriverWrapper and javascriptExecutor.
WebElement shadowHost = seleniumWebDriver.findElement(By.cssSelector("#shadowrootcontainer"));
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) seleniumWebDriver;
SearchContext shadowRoot = (SearchContext) javascriptExecutor.executeScript("return arguments[0].shadowRoot", shadowHost);
WebElement shadowContent = shadowRoot.findElement(By.cssSelector("#shadowcontentcss"));`
[This is in latest chrome driver] [Upgrading to selenium 4 is not working]
Any help would be much appreciated. Thanks in advance.