Iosnspredicate Appium positioning elements

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.