App automation test (iOS) element positioning (for beginners)

【Abstract】 In addition to general positioning methods, iOS has other special positioning methods. This chapter only introduces iOS-specific positioning methods. PredicateString positioning sample element screenshot: Using PredicateString, the basic positioning method is composed of element attribute name, operator, and target value. Element attribute comparison operators ==, >=, <=, >, <, !=, <>, which can be used to compare values ​​or strings For example: label == "SYSTEM (TEXT)" logical operators AND, OR, NOT , AND is equivalent to...

In addition to general positioning methods, iOS also has other special positioning methods. This chapter only introduces iOS-specific positioning methods.

PredicateString positioning

Sample element screenshot:


Using PredicateString, the basic positioning method is composed of element attribute name, operator, and target value.

element attribute

comparison operator

==, >=, <=, >, <, !=, <>, can be used to compare values ​​or strings
For example:

label == "SYSTEM (TEXT)"

Logical Operators

AND, OR, NOT, AND are equivalent to &&; OR are equivalent to ||; NOT are equivalent to !
For example:

label == "SYSTEM (TEXT)" AND enabled == true
label == "SYSTEM (TEXT)" OR name == "SYSTEM (TEXT)"
label == "SYSTEM (TEXT)" && NOT enabled != true

Fuzzy match LIKE

Both ? and * can be used as wildcards, ? matches one character, and * matches multiple characters.
For example:

label LIKE "SYSTEM (TEXT)"
label LIKE "?YSTEM (TEXT)"
label LIKE "SYSTEM??TEXT)"
label LIKE "* (TEXT)"
label LIKE "SYSTEM*"

other

BEGINSWITH,ENDSWITH,CONTAINS
例如:

# 匹配属性为 label ,value为 SYSTEM 开头的元素
label BEGINSWITH "SYSTEM"
# 匹配属性为 label ,value为 (TEXT) 结尾的元素
label ENDSWITH "(TEXT)"
# 匹配属性为 label ,value包含 TEXT 结尾的元素
label CONTAINS "TEXT"

For other positioning, please refer to the App Control Positioning chapter. If you have other knowledge points you want to know, you can also leave a message below!

 

Guess you like

Origin blog.csdn.net/NHB456789/article/details/131047932