32
32
@ EqualsAndHashCode (callSuper = true )
33
33
public abstract class AppiumBy extends By implements Remotable {
34
34
35
- @ Getter private final Parameters remoteParameters ;
35
+ @ Getter
36
+ private final Parameters remoteParameters ;
36
37
private final String locatorName ;
37
38
38
39
protected AppiumBy (String selector , String locatorString , String locatorName ) {
@@ -41,15 +42,18 @@ protected AppiumBy(String selector, String locatorString, String locatorName) {
41
42
this .locatorName = locatorName ;
42
43
}
43
44
44
- @ Override public List <WebElement > findElements (SearchContext context ) {
45
+ @ Override
46
+ public List <WebElement > findElements (SearchContext context ) {
45
47
return context .findElements (this );
46
48
}
47
49
48
- @ Override public WebElement findElement (SearchContext context ) {
50
+ @ Override
51
+ public WebElement findElement (SearchContext context ) {
49
52
return context .findElement (this );
50
53
}
51
54
52
- @ Override public String toString () {
55
+ @ Override
56
+ public String toString () {
53
57
return String .format ("%s.%s: %s" , AppiumBy .class .getSimpleName (), locatorName , remoteParameters .value ());
54
58
}
55
59
@@ -59,6 +63,7 @@ protected AppiumBy(String selector, String locatorString, String locatorName) {
59
63
* About iOS accessibility
60
64
* https://developer.apple.com/library/ios/documentation/UIKit/Reference/
61
65
* UIAccessibilityIdentification_Protocol/index.html
66
+ *
62
67
* @param accessibilityId id is a convenient UI automation accessibility Id.
63
68
* @return an instance of {@link AppiumBy.ByAndroidUIAutomator}
64
69
*/
@@ -68,9 +73,10 @@ public static By accessibilityId(final String accessibilityId) {
68
73
69
74
/**
70
75
* This locator strategy is only available in Espresso Driver mode.
76
+ *
71
77
* @param dataMatcherString is a valid json string detailing hamcrest matcher for Espresso onData().
72
- * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
73
- * the documentation</a> for more details
78
+ * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
79
+ * the documentation</a> for more details
74
80
* @return an instance of {@link AppiumBy.ByAndroidDataMatcher}
75
81
*/
76
82
public static By androidDataMatcher (final String dataMatcherString ) {
@@ -79,6 +85,7 @@ public static By androidDataMatcher(final String dataMatcherString) {
79
85
80
86
/**
81
87
* Refer to https://developer.android.com/training/testing/ui-automator
88
+ *
82
89
* @param uiautomatorText is Android UIAutomator string
83
90
* @return an instance of {@link AppiumBy.ByAndroidUIAutomator}
84
91
*/
@@ -88,9 +95,10 @@ public static By androidUIAutomator(final String uiautomatorText) {
88
95
89
96
/**
90
97
* This locator strategy is only available in Espresso Driver mode.
98
+ *
91
99
* @param viewMatcherString is a valid json string detailing hamcrest matcher for Espresso onView().
92
- * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
93
- * the documentation</a> for more details
100
+ * See <a href="http://appium.io/docs/en/writing-running-appium/android/espresso-datamatcher-selector/">
101
+ * the documentation</a> for more details
94
102
* @return an instance of {@link AppiumBy.ByAndroidViewMatcher}
95
103
*/
96
104
public static By androidViewMatcher (final String viewMatcherString ) {
@@ -99,9 +107,10 @@ public static By androidViewMatcher(final String viewMatcherString) {
99
107
100
108
/**
101
109
* This locator strategy is available in Espresso Driver mode.
102
- * @since Appium 1.8.2 beta
110
+ *
103
111
* @param tag is a view tag string
104
112
* @return an instance of {@link ByAndroidViewTag}
113
+ * @since Appium 1.8.2 beta
105
114
*/
106
115
public static By androidViewTag (final String tag ) {
107
116
return new ByAndroidViewTag (tag );
@@ -110,6 +119,7 @@ public static By androidViewTag(final String tag) {
110
119
/**
111
120
* For IOS it is the full name of the XCUI element and begins with XCUIElementType.
112
121
* For Android it is the full name of the UIAutomator2 class (e.g.: android.widget.TextView)
122
+ *
113
123
* @param selector the class name of the element
114
124
* @return an instance of {@link ByClassName}
115
125
*/
@@ -120,6 +130,7 @@ public static By className(final String selector) {
120
130
/**
121
131
* For IOS the element name.
122
132
* For Android it is the resource identifier.
133
+ *
123
134
* @param selector element id
124
135
* @return an instance of {@link ById}
125
136
*/
@@ -130,6 +141,7 @@ public static By id(final String selector) {
130
141
/**
131
142
* For IOS the element name.
132
143
* For Android it is the resource identifier.
144
+ *
133
145
* @param selector element id
134
146
* @return an instance of {@link ByName}
135
147
*/
@@ -153,21 +165,22 @@ public static By custom(final String selector) {
153
165
* This locator strategy is available only if OpenCV libraries and
154
166
* Node.js bindings are installed on the server machine.
155
167
*
168
+ * @param b64Template base64-encoded template image string. Supported image formats are the same
169
+ * as for OpenCV library.
170
+ * @return an instance of {@link ByImage}
156
171
* @see <a href="https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/image-comparison.md">
157
172
* The documentation on Image Comparison Features</a>
158
173
* @see <a href="https://github.com/appium/appium-base-driver/blob/master/lib/basedriver/device-settings.js">
159
174
* The settings available for lookup fine-tuning</a>
160
175
* @since Appium 1.8.2
161
- * @param b64Template base64-encoded template image string. Supported image formats are the same
162
- * as for OpenCV library.
163
- * @return an instance of {@link ByImage}
164
176
*/
165
177
public static By image (final String b64Template ) {
166
178
return new ByImage (b64Template );
167
179
}
168
180
169
181
/**
170
182
* This locator strategy is available in XCUITest Driver mode.
183
+ *
171
184
* @param iOSClassChainString is a valid class chain locator string.
172
185
* See <a href="https://github.com/facebookarchive/WebDriverAgent/wiki/Class-Chain-Queries-Construction-Rules">
173
186
* the documentation</a> for more details
@@ -179,13 +192,64 @@ public static By iOSClassChain(final String iOSClassChainString) {
179
192
180
193
/**
181
194
* This locator strategy is available in XCUITest Driver mode.
195
+ *
182
196
* @param iOSNsPredicateString is an iOS NsPredicate String
183
197
* @return an instance of {@link AppiumBy.ByIosNsPredicate}
184
198
*/
185
199
public static By iOSNsPredicateString (final String iOSNsPredicateString ) {
186
200
return new ByIosNsPredicate (iOSNsPredicateString );
187
201
}
188
202
203
+ /**
204
+ * This locator strategy is available in FlutterIntegration Driver mode.
205
+ *
206
+ * @param selector is the value defined to the key attribute of the flutter element
207
+ * @return an instance of {@link AppiumBy.ByFlutterKey}
208
+ */
209
+ public static By flutterKey (final String selector ) {
210
+ return new ByFlutterKey (selector );
211
+ }
212
+
213
+ /**
214
+ * This locator strategy is available in FlutterIntegration Driver mode.
215
+ *
216
+ * @param selector is the Type of widget mounted in the app tree
217
+ * @return an instance of {@link AppiumBy.ByFlutterType}
218
+ */
219
+ public static By flutterType (final String selector ) {
220
+ return new ByFlutterType (selector );
221
+ }
222
+
223
+ /**
224
+ * This locator strategy is available in FlutterIntegration Driver mode.
225
+ *
226
+ * @param selector is the text that is present on the widget
227
+ * @return an instance of {@link AppiumBy.ByFlutterText}
228
+ */
229
+ public static By flutterText (final String selector ) {
230
+ return new ByFlutterText (selector );
231
+ }
232
+
233
+ /**
234
+ * This locator strategy is available in FlutterIntegration Driver mode.
235
+ *
236
+ * @param selector is the text that is partially present on the widget
237
+ * @return an instance of {@link AppiumBy.ByFlutterTextContaining}
238
+ */
239
+ public static By flutterTextContaining (final String selector ) {
240
+ return new ByFlutterTextContaining (selector );
241
+ }
242
+
243
+ /**
244
+ * This locator strategy is available in FlutterIntegration Driver mode.
245
+ *
246
+ * @param semanticsLabel represents the value assigned to the label attribute of semantics element
247
+ * @return an instance of {@link AppiumBy.ByFlutterSemanticsLabel}
248
+ */
249
+ public static By flutterSemanticsLabel (final String semanticsLabel ) {
250
+ return new ByFlutterSemanticsLabel (semanticsLabel );
251
+ }
252
+
189
253
public static class ByAccessibilityId extends AppiumBy implements Serializable {
190
254
public ByAccessibilityId (String accessibilityId ) {
191
255
super ("accessibility id" , accessibilityId , "accessibilityId" );
@@ -257,4 +321,41 @@ protected ByIosNsPredicate(String locatorString) {
257
321
super ("-ios predicate string" , locatorString , "iOSNsPredicate" );
258
322
}
259
323
}
324
+
325
+ public abstract static class FlutterBy extends AppiumBy {
326
+ protected FlutterBy (String selector , String locatorString , String locatorName ) {
327
+ super (selector , locatorString , locatorName );
328
+ }
329
+ }
330
+
331
+ public static class ByFlutterType extends FlutterBy implements Serializable {
332
+ protected ByFlutterType (String locatorString ) {
333
+ super ("-flutter type" , locatorString , "flutterType" );
334
+ }
335
+ }
336
+
337
+ public static class ByFlutterKey extends FlutterBy implements Serializable {
338
+ protected ByFlutterKey (String locatorString ) {
339
+ super ("-flutter key" , locatorString , "flutterKey" );
340
+ }
341
+ }
342
+
343
+ public static class ByFlutterSemanticsLabel extends FlutterBy implements Serializable {
344
+ protected ByFlutterSemanticsLabel (String locatorString ) {
345
+ super ("-flutter semantics label" , locatorString , "flutterSemanticsLabel" );
346
+ }
347
+ }
348
+
349
+ public static class ByFlutterText extends FlutterBy implements Serializable {
350
+ protected ByFlutterText (String locatorString ) {
351
+ super ("-flutter text" , locatorString , "flutterText" );
352
+ }
353
+ }
354
+
355
+ public static class ByFlutterTextContaining extends FlutterBy implements Serializable {
356
+ protected ByFlutterTextContaining (String locatorString ) {
357
+ super ("-flutter text containing" , locatorString , "flutterTextContaining" );
358
+ }
359
+ }
360
+
260
361
}
0 commit comments