16
16
17
17
package io .appium .java_client ;
18
18
19
- import lombok .AccessLevel ;
20
19
import lombok .Getter ;
21
- import lombok .NoArgsConstructor ;
22
20
import org .apache .commons .lang3 .Validate ;
23
21
import org .openqa .selenium .By ;
24
22
import org .openqa .selenium .By .Remotable ;
31
29
32
30
public abstract class AppiumBy extends By implements Remotable {
33
31
34
- @ Getter private final Parameters remoteParameters ;
32
+ @ Getter
33
+ private final Parameters remoteParameters ;
35
34
private final String locatorName ;
36
35
37
36
protected AppiumBy (String selector , String locatorString , String locatorName ) {
@@ -40,15 +39,18 @@ protected AppiumBy(String selector, String locatorString, String locatorName) {
40
39
this .locatorName = locatorName ;
41
40
}
42
41
43
- @ Override public List <WebElement > findElements (SearchContext context ) {
42
+ @ Override
43
+ public List <WebElement > findElements (SearchContext context ) {
44
44
return context .findElements (this );
45
45
}
46
46
47
- @ Override public WebElement findElement (SearchContext context ) {
47
+ @ Override
48
+ public WebElement findElement (SearchContext context ) {
48
49
return context .findElement (this );
49
50
}
50
51
51
- @ Override public String toString () {
52
+ @ Override
53
+ public String toString () {
52
54
return String .format ("%s.%s: %s" , AppiumBy .class .getSimpleName (), locatorName , remoteParameters .value ());
53
55
}
54
56
@@ -58,6 +60,7 @@ protected AppiumBy(String selector, String locatorString, String locatorName) {
58
60
* About iOS accessibility
59
61
* <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/">https://developer.apple.com/library/ios/documentation/UIKit/Reference/</a>
60
62
* UIAccessibilityIdentification_Protocol/index.html
63
+ *
61
64
* @param accessibilityId id is a convenient UI automation accessibility Id.
62
65
* @return an instance of {@link AppiumBy.ByAndroidUIAutomator}
63
66
*/
@@ -67,9 +70,10 @@ public static By accessibilityId(final String accessibilityId) {
67
70
68
71
/**
69
72
* This locator strategy is only available in Espresso Driver mode.
73
+ *
70
74
* @param dataMatcherString is a valid json string detailing hamcrest matcher for Espresso onData().
71
- * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
72
- * the documentation</a> for more details
75
+ * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
76
+ * the documentation</a> for more details.
73
77
* @return an instance of {@link AppiumBy.ByAndroidDataMatcher}
74
78
*/
75
79
public static By androidDataMatcher (final String dataMatcherString ) {
@@ -78,6 +82,7 @@ public static By androidDataMatcher(final String dataMatcherString) {
78
82
79
83
/**
80
84
* Refer to <a href="https://developer.android.com/training/testing/ui-automator">https://developer.android.com/training/testing/ui-automator</a>
85
+ *
81
86
* @param uiautomatorText is Android UIAutomator string
82
87
* @return an instance of {@link AppiumBy.ByAndroidUIAutomator}
83
88
*/
@@ -87,9 +92,10 @@ public static By androidUIAutomator(final String uiautomatorText) {
87
92
88
93
/**
89
94
* This locator strategy is only available in Espresso Driver mode.
95
+ *
90
96
* @param viewMatcherString is a valid json string detailing hamcrest matcher for Espresso onView().
91
- * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
92
- * the documentation</a> for more details
97
+ * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
98
+ * the documentation</a> for more details
93
99
* @return an instance of {@link AppiumBy.ByAndroidViewMatcher}
94
100
*/
95
101
public static By androidViewMatcher (final String viewMatcherString ) {
@@ -98,9 +104,10 @@ public static By androidViewMatcher(final String viewMatcherString) {
98
104
99
105
/**
100
106
* This locator strategy is available in Espresso Driver mode.
101
- * @since Appium 1.8.2 beta
107
+ *
102
108
* @param tag is a view tag string
103
109
* @return an instance of {@link ByAndroidViewTag}
110
+ * @since Appium 1.8.2 beta
104
111
*/
105
112
public static By androidViewTag (final String tag ) {
106
113
return new ByAndroidViewTag (tag );
@@ -109,6 +116,7 @@ public static By androidViewTag(final String tag) {
109
116
/**
110
117
* For IOS it is the full name of the XCUI element and begins with XCUIElementType.
111
118
* For Android it is the full name of the UIAutomator2 class (e.g.: android.widget.TextView)
119
+ *
112
120
* @param selector the class name of the element
113
121
* @return an instance of {@link ByClassName}
114
122
*/
@@ -119,6 +127,7 @@ public static By className(final String selector) {
119
127
/**
120
128
* For IOS the element name.
121
129
* For Android it is the resource identifier.
130
+ *
122
131
* @param selector element id
123
132
* @return an instance of {@link ById}
124
133
*/
@@ -129,6 +138,7 @@ public static By id(final String selector) {
129
138
/**
130
139
* For IOS the element name.
131
140
* For Android it is the resource identifier.
141
+ *
132
142
* @param selector element id
133
143
* @return an instance of {@link ByName}
134
144
*/
@@ -152,24 +162,25 @@ public static By custom(final String selector) {
152
162
* This locator strategy is available only if OpenCV libraries and
153
163
* Node.js bindings are installed on the server machine.
154
164
*
165
+ * @param b64Template base64-encoded template image string. Supported image formats are the same
166
+ * as for OpenCV library.
167
+ * @return an instance of {@link ByImage}
155
168
* @see <a href="https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/image-comparison.md">
156
169
* The documentation on Image Comparison Features</a>
157
170
* @see <a href="https://github.com/appium/appium-base-driver/blob/master/lib/basedriver/device-settings.js">
158
171
* The settings available for lookup fine-tuning</a>
159
172
* @since Appium 1.8.2
160
- * @param b64Template base64-encoded template image string. Supported image formats are the same
161
- * as for OpenCV library.
162
- * @return an instance of {@link ByImage}
163
173
*/
164
174
public static By image (final String b64Template ) {
165
175
return new ByImage (b64Template );
166
176
}
167
177
168
178
/**
169
179
* This locator strategy is available in XCUITest Driver mode.
180
+ *
170
181
* @param iOSClassChainString is a valid class chain locator string.
171
- * See <a href="https://github.com/facebookarchive/WebDriverAgent/wiki/Class-Chain-Queries-Construction-Rules">
172
- * the documentation</a> for more details
182
+ *See <a href="https://github.com/facebookarchive/WebDriverAgent/wiki/Class-Chain-Queries-Construction-Rules">
183
+ * the documentation</a> for more details
173
184
* @return an instance of {@link AppiumBy.ByIosClassChain}
174
185
*/
175
186
public static By iOSClassChain (final String iOSClassChainString ) {
@@ -178,6 +189,7 @@ public static By iOSClassChain(final String iOSClassChainString) {
178
189
179
190
/**
180
191
* This locator strategy is available in XCUITest Driver mode.
192
+ *
181
193
* @param iOSNsPredicateString is an iOS NsPredicate String
182
194
* @return an instance of {@link AppiumBy.ByIosNsPredicate}
183
195
*/
@@ -247,7 +259,8 @@ protected ByImage(String b64Template) {
247
259
248
260
public static class ByIosClassChain extends AppiumBy implements Serializable {
249
261
protected ByIosClassChain (String locatorString ) {
250
- super ("-ios class chain" , locatorString , "iOSClassChain" );
262
+ super ("-ios class chain" , locatorString ,
263
+ "iOSClassChain" );
251
264
}
252
265
}
253
266
@@ -259,9 +272,15 @@ protected ByIosNsPredicate(String locatorString) {
259
272
260
273
@ Override
261
274
public boolean equals (Object o ) {
262
- if (this == o ) return true ;
263
- if (o == null || getClass () != o .getClass ()) return false ;
264
- if (!super .equals (o )) return false ;
275
+ if (this == o ) {
276
+ return true ;
277
+ }
278
+ if (o == null || getClass () != o .getClass ()) {
279
+ return false ;
280
+ }
281
+ if (!super .equals (o )) {
282
+ return false ;
283
+ }
265
284
AppiumBy appiumBy = (AppiumBy ) o ;
266
285
return Objects .equals (remoteParameters , appiumBy .remoteParameters ) && Objects .equals (locatorName , appiumBy .locatorName );
267
286
}
0 commit comments