Issue
How do I get the parent element of any given element in selenium with ruby?
Let's say I have this:
<ul>
<li id="a"></li>
</ul>
and I can get the li with driver.find_element(id: "a")
, how do I get the parent of that element that I found?
Solution
This code will help you to find the parent element
element = driver.find_element(id: "a")
element.find_element(xpath: "./..")
This code will help you to verify the element html
p element.find_element(xpath: "./..").attribute("innerHTML")
Answered By - Rajagopalan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.