Selenium Version: 4.0.0
Are there alternative methods to implement isDisplayed, isEnabled, isSelected using Java script for shadow dom elements in Selenium?
I attempted the steps below but unfortunately they did not work. Any advice would be appreciated.
Code:
public void isEnabledUsingJavaScript() {
JavascriptExecutor js = (JavascriptExecutor) driver;
Boolean test= (Boolean) js.executeScript("document.querySelector("foo >boo").shadowRoot.querySelector("foo>boo>span").enable()");
System.out.println(test);
}
Note: Due to being within a shadow dom, regular XPATH or CSS selectors cannot be used.
Error:-
org.openqa.selenium.JavascriptException: javascript error: document.querySelector(...).shadowRoot.querySelector(...).enable is not a function
Although I understand the issue, I am unsure of which appropriate method in JavaScript can be utilized in such scenarios.