The appium1.4.x I used before reinstalling the system is now 1.5.3, and I run the use cases that were successful on 1.4.X on 1.5.3. The result is an error. Said Find_element_by_name no longer supports it.
Immediately Baidu, online indeed said Appium has put this excuse to shut down. Then can only use XPath to set as, the effect is not very good, online query the information, because Appium is to open instruments, so provide an element of the positioning method is find_element_by_i0s_uiautomation. This positioning method is quick to locate elements, and is relatively fast and efficient compared to XPath.
But what are the rules for positioning? At the beginning I looked at the information and experience posted on the Internet. But still do not know how to position, because the location of the name does not know how to write.
If you are familiar with the automation in instruments, then this is very simple. If not, suggest to learn, an estimated 10 minutes will be able to record the script, we need to get the element positioning information on it. Whether the script can run doesn't concern you.
Like XPath,
Uiatableview/uiatablecell/uiastatictext
In the I0s_uiautomation
. Tableviews () [0].cells () [0].statictexts () [0]
. Tableviews (). Firstwithpredicate ("Value like ' rows 1 to 2 of 7 '"). Cells () ["featured"].buttons () [Query More]
The elements that are positioned in the above two ways are the same, but because of the matching lookup, even if the future position changes, may also use matching lookup to locate, with the XPath positioning of the know write dead positioning, as long as a slight adjustment, the script needs to be fully written, the workload can be large and small, but in general no benefit.
Automation also provides a way to query the syntax predicate
(1) comparison operator >,<,==,>=,<=,!=
Can be used for numeric and string
Example: @ "number > 100"
(2) Range operator: in, BETWEEN
Example: @ "number BETWEEN {1,5}"
@ "address in {' Shanghai ', ' Beijing '}"
(3) string itself: SELF
Example: @ "SELF = = ' APPLE '"
(4) String Related: Beginswith, ENDSWITH, CONTAINS
Example: @ "name CONTAIN[CD] ' ang '//contains a string
@ "name Beginswith[c] ' sh '"//begins with a string
@ "name Endswith[d] ' ang '"//End with a string
Note: [c] case-insensitive [d] does not distinguish between pronounced symbols, which are not accented [CDs] are neither case-sensitive nor distinguish between pronounced symbols.
(5) wildcard character: like
Example: @ "name LIKE[CD] ' *er* '"//* represents wildcard characters and like also accepts [CDs].
@ "name LIKE[CD] '??? Er* ' "
(6) Regular expression: matches
Example: NSString *regex = @ "^a.+e$"; Beginning with a, E ending
@ "name matches%@", regex
Summarizes the contrast between XPath and I0s_uiautomation.
1.uiatableview:tableviews ()
2.uiatablecell:cells ()
3.uiastatictext:statictexts ()
4.uiabutton:buttons ()
5.: Textfields ()
6.:alert ()
7.:switches ()
8.:sliders ()
October 25
Today, the first time in actual combat with predicate, thought very simple, in fact, or met a pit.
Got the location statement with Automation.
. Statictexts (). Firstwithpredicate ("Value like" login, immediately add the column of interest to Here ' ")
According to the usual wording should be
Elem = Driver.find_element_by_os_uiautomation (". Statictexts (). Firstwithpredicate (" Value like "login, immediately add the column of interest to Here '") ")
Because of Python's syntax, do not recognize "" in the Reuse ""
After a burst of debugging before running through, please see the following I wrote the case
Elem = Driver.find_element_by_ios_uiautomation (". Statictexts (). Firstwithpredicate (" + "" ' + "value beginswith ' login ' + ') "'+")")
is to use + "stitching" into the positioning statement.
Also used here Beginswith because I'm afraid in the future if the prompt text shown here needs to be modified, but the previous few words may be modified very small, so the fuzzy matching to find.