1

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.

Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12
SRM21
  • 453
  • 5
  • 14

2 Answers2

1

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.

Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12
1

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")
Muzzamil
  • 2,823
  • 2
  • 11
  • 23
Vikas
  • 11
  • 4