Appium after using Webdriveragent, a new location method Iosnspredicate is added, summarizing how to use it:
Mobileelement photo = Driver.findelementbyiosnspredicate ("name = ' head new '"); Equals
Mobileelement photo = Driver.findelementbyiosnspredicate ("Name like ' *new '"); Fuzzy matching
Mobileelement photo = Driver.findelementbyiosnspredicate ("name MATCHES ' ^$ '"); Regular expression Matching
list<ioselement> items1 = driver.findelementsbyiosnspredicate ("Name CONTAINS ' my '"); Contains
list<ioselement> items2 = driver.findelementsbyiosnspredicate ("Name Beginswith ' my '"); Start with "my"
list<ioselement> items3 = driver.findelementsbyiosnspredicate ("Name Beginswith ' my ' && name ENDSWITH ' message ' "); Start with "my" and End with "message"
Where the property name refers to the attribute field of Inspector, the keyword Like,matches,contains,beginswith,endswith must be uppercase, and the matching characters need to be in single quotation marks
Official reference Address:
Https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/ios_predicate.md
Finally, give a suggestion:
1 The choice of positioning method of judgment:
If the text displayed in the interface is unique or the first one appears: Use accessibility
If class is unique or the first one appears: ClassName
The ID or class is not easy to locate and the control property has an explicit matching rule: accessibility
If there is a tool that can directly give the exact xpath:xpath
You can't just use coordinates.
2 If the control's property visible is false, use control coordinates and get the center point tap with Tap, and clicking the control directly fails
Iosnspredicate Appium positioning elements