appium -mac ios targeting

1 Introduction

The use of id, className, AccessibilityId targeting relatively simple, in most cases, on the same page, not only existing, an element can not be recognized. The xpath targeting is not supported in the underlying native xcui by appium additional support, the positioning speed is very slow, and the situation is sometimes less than the positioning elements present. iOSNsPredicateString targeting summary, the iOS UI Automation, a native support is the best support is the best.

2 targeting

Full support iOS version, the bottom frame tests whether or UIAutomation XCUITest, a single support element property and locating a plurality of attributes, is recommended. An element with these properties: type, value, name, label, enabled, visible, or more properties of some elements only some of the attributes, shown below, the elements can be positioned based on these attributes.

 

Introduction 3 element property

type: element type, consistent with className effects, such as: XCUIElementTypeStaticText
value: generally do not
name: text content elements can be used as AccessibilityId positioning methods, such as: test 420 class group
label: In most cases, consistent with the name role
enabled : The element can be clicked, the general value of true or false
visible: the element is visible, the general value of true or false

4 elements targeting

Targeting element is an attribute value + + operator form of

1, comparison operators:!>, <, ==,> =, <=, =
can be used to compare strings and values,
such as: name> 100 or name == 'test'

 

2, the range operator: IN, BETWEEN
can be used for checking the values and character strings
such as: name BETWEEN {3,10}, name IN { 'Alan', 'May'}

 

3, the string associated: CONTAINS, BEGINSWITH, ENDSWITH
comprising a string, such as: label CONTAINS 'test'
beginning with a string, such as: label BEGINSWITH '420'
ends with a string, such as: label ENDSWITH ' group classes'
the PS: after three keywords plus [c] is not case-sensitive, can be used to check letters; [D] does not distinguish between the pronunciation symbol, i.e. without accents ($, #,%, etc.); [ cd] That is case-insensitive, nor distinguish pronunciation symbol, such as: name CONTAINS [c] ABcd and name CONTAINS abcd, name CONTAINS ABCD are equivalent, the latter two not bring attention [c] is not equal to

 

4, wildcards: LIKE
Wildcard accept [cd] ,? represents a character, * representing a plurality of characters
such as: label attribute element to a

label LIKE '420 test class group'

label LIKE '420 measured? class group'

label LIKE '420 ?? class group'

label LIKE '42? Test ban? group'

label LIKE '* Test group class'

label LIKE '420 * Test Ban'

label LIKE '42 *-level group '

label LIKE '4 * * Test group'

Over so many texts can be identified as the same element.

 

5, regular expressions: MATCHES
such as: start with 4 to end group,

label MATCHES '^4.+群$'

 

5 is an attribute positioning element

Element attributes can be used: type, value, name, label, enabled, visible, positioning:

type == XCUIElementTypeStaticText,

label CONTAINS 'test'

label LIKE '* Test group class'

enabled == true

visible == false

 

6 two or more attributes of the positioning element

It is positioned above a single attribute symbol connected to AND. Such as:

type == XCUIElementTypeStaticText AND labelCONTAINS '测试

type == XCUIElementTypeStaticText AND labelCONTAINS '测试' AND enabled == true

 

7 Use

// equal

MobileElement photo = driver.findElementByIosNsPredicate("name= ‘head new‘");

 

 // fuzzy matching

MobileElement photo =driver.findElementByIosNsPredicate("name LIKE ‘*new‘");

 

// regular expression match

MobileElement photo = driver.findElementByIosNsPredicate("nameMATCHES ‘^$‘");

 

// Include

List<IOSElement> items1 = driver.findElementsByIosNsPredicate("nameCONTAINS ‘我的‘");

 

// to "my" start

List<IOSElement> items2 = driver.findElementsByIosNsPredicate("nameBEGINSWITH ‘我的‘");

 

// to "my" and ending with "news" at the end

List<IOSElement> items3 = driver.findElementsByIosNsPredicate("nameBEGINSWITH ‘我的‘ && name ENDSWITH ‘消息‘");

 

Where the property names refer inspector attribute field, keyword LIKE, MATCHES, CONTAINS, BEGINSWITH, ENDSWITH must be uppercase characters to match the needs of single quotes

 

 References:

https://testerhome.com/topics/9405

 

http://www.mamicode.com/info-detail-1839942.html

 Transfer: https://blog.csdn.net/wangmcn1984/article/details/78963178

 

Guess you like

Origin www.cnblogs.com/dreamhighqiu/p/10990063.html