Skip to content

Commit 19fb322

Browse files
authoredDec 8, 2016
update some tips for finding elements (#412)
1 parent e485121 commit 19fb322

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed
 

‎docs/ios_xcuitest.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,49 @@
55
- How to migrate XCUITest from UIAutomation
66
- [Migrating your iOS tests from UIAutomation](https://github.com/appium/appium/blob/v1.6.2/docs/en/advanced-concepts/migrating-to-xcuitest.md)
77

8-
9-
### Elements
8+
## find elements
109
- supported elements by find_element is:
1110
- [appium-xcuitest-driver](https://github.com/appium/appium-xcuitest-driver/blob/master/lib/commands/find.js#L17)
1211
- [WebDriverAgent](https://github.com/facebook/WebDriverAgent/blob/8346199212bffceab24192e81bc0118d65132466/WebDriverAgentLib/Commands/FBFindElementCommands.m#L111)
1312
- Mapping
1413
- https://github.com/facebook/WebDriverAgent/blob/master/WebDriverAgentLib/Utilities/FBElementTypeTransformer.m#L19
1514

16-
### XPath
15+
### with except for XPath
16+
#### examples
17+
- [button_class](https://github.com/appium/ruby_lib/blob/master/lib/appium_lib/ios/element/button.rb#L8), [static_text_class](https://github.com/appium/ruby_lib/blob/master/lib/appium_lib/ios/element/text.rb#L8), [text_field_class](https://github.com/appium/ruby_lib/blob/master/lib/appium_lib/ios/element/textfield.rb#L10) and [secure_text_field_class](https://github.com/appium/ruby_lib/blob/master/lib/appium_lib/ios/element/textfield.rb#L15) provide class name.
18+
- If `automationName` is `Appium`, then they provide `UIAxxxx`
19+
- If `automationName` is `XCUITest`, then they provide `XCUIElementTypexxx`
20+
21+
```ruby
22+
find_element(:class, button_class) # Return a element of XCUIElementTypeButton for XCUITest
23+
```
24+
25+
- [tag/s](https://github.com/appium/ruby_lib/blob/ac03116756a72fbd624fa32ea886123b955d7089/lib/appium_lib/android/helper.rb#L238) is alias of `find_element :class, element`
26+
27+
- `accessibility_id`
28+
29+
```ruby
30+
find_element(:accessibility_id, element) # Return a element which has accessibilityIdentifier, `element`.
31+
```
32+
33+
### with XPath
1734
- It is better to avoid XPath strategy.
1835
- https://github.com/appium/appium/blob/v1.6.2/docs/en/advanced-concepts/migrating-to-xcuitest.md#xpath-locator-strategy
19-
> Try not to use XPath locators unless there is absolutely no other alternatives. In general, xpath locators might be times slower, than other types of locators like accessibility id, class name and predicate (up to 100 times slower in some special cases). They are so slow, because xpath location is not natively supported by Apple's XCTest framework.
36+
- > Try not to use XPath locators unless there is absolutely no other alternatives. In general, xpath locators might be times slower, than other types of locators like accessibility id, class name and predicate (up to 100 times slower in some special cases). They are so slow, because xpath location is not natively supported by Apple's XCTest framework.
2037
- Improved performance a bit
2138
- https://github.com/appium/appium/issues/6842
2239
- https://github.com/facebook/WebDriverAgent/issues/306
2340
- XPath in WebDriverAgent
2441
- https://github.com/facebook/WebDriverAgent/blob/2158a8d0f305549532f1338fe1e4628cfbd53cd9/WebDriverAgentLib/Categories/XCElementSnapshot%2BFBHelpers.m#L57
2542

43+
#### examples
44+
- `button/s(value)`, `textfield/s(value)`, `text/s(value)` uses XPath in their method. So, these methods are slower than other find_element directly.
45+
46+
```ruby
47+
button(value) # Return a XCUIElementTypeButton element which has `value` text.
48+
textfield(value) # Return a XCUIElementTypeSecureTextField or XCUIElementTypeTextField element which has `value` text.
49+
text(value) # Return a XCUIElementTypeStaticText element which has `value` text.
50+
```
51+
52+
## Other actions
53+
Basically, other actions such as `type` is compatible with `automationName = Appium`.

0 commit comments

Comments
 (0)
Please sign in to comment.