I’m trying to convert the following xpath to find the same element, but using css selectors instead:
//div/select[@class='specific_class']/../../button[@type='submit']
The HTML looks approximately like the following, and I want the button element.
<div>
<select class="specific_class">
<options>
</select>
</div>
<button type="submit">
Is this possible using CSS Selectors?
No, CSS selectors cannot ascend an element hierarchy after descending it. In other words, there isn’t any syntax that works like XPath’s
..node, nor is there any syntax to check if a parent element has a certain child element.