falukky
falukky

Reputation: 1139

PYthon and Appium: how to go to parent element

I am working with iOS and appium to control my application.

So i have this element that i want to jump into its parent:

elements = self.driver.find_elements_by_ios_predicate('bla bla')

This is what i have try:

parent = elements[0] .find_element_by_xpath('./..')

I also try this:

parent = elements[0] .find_element_by_xpath('/..')

And in both cases i cannot fine the parent.

Upvotes: 0

Views: 1072

Answers (1)

sohum
sohum

Reputation: 54

XPath is a good locator strategy to find an element's parent.

parent = self.driver.find_element_by_xpath('blabla/parent::*')

This will return the element's parent, where blabla is the XPath for element from your example. More on XPath Axes here.

Upvotes: 1

Related Questions