I am attempting to interact with a dropdown menu in order to track activity on the page when clicking on one of its items.
Here is an overview of my HTML structure:
<slot>
#shadowroot
<myoption-cmp> #shadowroot <some anchor text>
<myoption-cmp> #shadowroot <some anchor text>
</slot>
However, when using findElements(By.cssSelector('myoption-cmp')), I keep encountering the error "org.openqa.selenium.WebDriverException: javascript error: Cannot read property 'querySelectorAll' of null". Below is a snippet of my Selenium code:
WebElement slot = parentElement.findElement(By.cssSelector("slot"));
WebElement shadowSlot = expandShadow(slot);
List<WebElement> menuCmp = shadowSlot.findElements(By.cssSelector("myoption-cmp"));
// Accessing the list of elements
WebElement shadow2 = expandShadow(menuCmp.get(0));
WebElement anchor = shadow2.findElement(By.cssSelector("a"));
anchor.click();
I have tried using findElement and findElements methods, but both result in errors such as "org.openqa.selenium.WebDriverException: javascript error: Cannot read property 'querySelector/querySelectorAll' of null". Any tips or suggestions would be greatly appreciated.
I attempted utilizing findElement and findElements, however, encountered errors like "org.openqa.selenium.WebDriverException: javascript error: Cannot read property 'querySelector/querySelectorAll' of null".
If anyone can provide assistance or advice, it would be highly valued.