SRM21
SRM21

Reputation: 503

Not able to locate element in appium by using xpath ends-with for iOS app created using react native

I am automating the flow of iOS app made using react native.

I am able to find elements by XPath normally but when trying the ends-with syntax, it is unable to find the element.

I am using python language, below is the example of code snippet I am using: self.driver.find_element_by_xpath("//XCUIElementTypeOther[ends-with(@name, 'locatorValue')]")

I tried to find the solution or example syntax to check if I am doing something wrong, but most of the times I was getting examples of Android only and also the syntax which I am using seems to be proper to me as per my understanding.

Is it a limitation that I can't use ends-with xpath for iOS app made using react native, or am I missing something here?

Kindly request to help me out.

Upvotes: 1

Views: 1625

Answers (2)

Vikas
Vikas

Reputation: 11

As explained in above comment iOSNsPredicateString can be used this way

self.driver.find_element_by_ios_predicate("type =='XCUIElementTypeOther' AND name ENDSWITH[c] 'locatorValue' AND enabled==1")

Upvotes: 1

Wasiq Bhamla
Wasiq Bhamla

Reputation: 959

You could simply use iOS NSPredicate expression like, self.driver.find_element_by_ios_predicate("name ENDSWITH 'locatorValue'")

This should work for you.

To know more about iOS predicates, check here.

Upvotes: 1

Related Questions