Find parent element
See original GitHub issueHow do I get the parent element (or ancestor / ancestors ) of an element? The next element would also be usefull.
I tried the following:
element.GetAttribute("Ancestors")
FindElement(By.XPath("./.."), element)
Both queries return null.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
HTML DOM parentElement Property
The parentElement property returns the parent element of the specified element. ... In most cases, it does not matter which property you use,...
Read more >JavaScript Get the Parent Element parentNode
JavaScript parentNode example · First, select the element with the .note class by using the querySelector() method. · Second, find the parent node...
Read more >Node: parentElement property - Web APIs | MDN
The read-only parentElement property of Node interface returns the DOM node's parent Element , or null if the node either has no parent, ......
Read more >Element: closest() method - Web APIs - MDN Web Docs - Mozilla
The closest() method of the Element interface traverses the element and its parents (heading toward the document root) until it finds a node...
Read more >Get the Parent of an Element - JavaScript Tutorial
First, select the element with the CSS selector #main · Then, use the parentNode property to get the parent element of the selected...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@liljohnak many thanks
I search the parent node successfully using the session.
The code above work well.
Another workaround, using the element ID to build an XPath expression for the parent: