How To Find Parent or Child Element

366 views
Skip to first unread message

Fowafolo

unread,
Apr 24, 2017, 10:26:55 AM4/24/17
to Selenium Users
Hello,

I'm really new to `Selenium` and I just wonder whether we are able to find the parent element or child element using Selenium:: WebDriver:: Element? For example, here are two UITableViewCell in the tableView and if I have gotten the top image element, how can I get the element with the text Wiki - R311 or the second image on the second UITableViewCell?

Moreover, I am using ruby to write the codes.










Thanks so much.

Monika Singhal

unread,
Apr 28, 2017, 1:04:50 PM4/28/17
to Selenium Users

Hi,

Yes you can find others elements if you have identified the top image element. You will have to find the path of other elements relative to the path of the top element. Please share the url and also the top element path with me so that I can compute the exact xpath for you. 

For example:



In this example, I have identified the first image and I have found the xpath of the other elements in the same row and in the other row relative to the top element.

The first image xpath : "//img[@src='http://phptravels.com/assets/img/front.png']"

Note: My xpath will definitely not match your xpath and even sequence will not be same. It all depends on the html source of the page
Reply all
Reply to author
Forward
0 new messages