SeleniumHQ / SeleniumHQ/selenium
[🚀 Feature]: Relative Locators support for ShadowRoot SearchContext
- Dominant language
- Java
- Stars
- 34.5k
- Forks
- 8.7k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 92
Description
### Feature and motivation
I am using Selenium v. 4.13
I have a shadow-root element, holding a complex account tree structure. It is required to validate that tree nodes have been rendered properly, according to account hierarchy, so that one element is above another, to the left or to the right.
Relative Locators in Selenium 4 are the ideal validation path, but trying to call findElement/s with relative locators throws the exception below:
**java.lang.IllegalArgumentException: Context does not provide a mechanism to execute JS:**
### Usage example
SearchContext shadowRoot = driver.findElement(shadowLocator).getShadowRoot();
elementList = shadowRoot.findElements(with(rootLocator).above(aboveLocator));
Result:
**java.lang.IllegalArgumentException: Context does not provide a mechanism to execute JS:** org.openqa.selenium.remote.ShadowRoot@5dbd1f7e
at org.openqa.selenium.By.getJavascriptExecutor (By.java:153)
at org.openqa.selenium.support.locators. RelativeLocator $RelativeBy.findElements (RelativeLocator.java:190)
Contributor guide
Assessment
This issue has not been assessed yet.