I have a structure such as this:
<div class="Container">
<div class="HighlightContainer">
<div class="NodeTextHighlightContainer">
<span class="TreeItemSelected">Products</span>
</div>
<button class="ContainerSelectedMenu" type="button"></button>
</div>
</div>
Because of how the DOM behaves and trying to stay dynamic, I can only target the span that contains text Products. using something like:
Driver.FindElement(By.XPath("//div[contains(@class, 'Container')]/descendant::span[text() = 'Products']"));
However, I need to target the button where class="ContainerSelectedMenu"
based of that span element, what is the best approach? Something like getting the parent div of the child of Container then finding the button element.