@@ -341,6 +341,58 @@ protected ByIosNsPredicate(String locatorString) {
341
341
return "By.IosNsPredicate: " + getLocatorString ();
342
342
}
343
343
}
344
+
345
+ public static class ByWindowsAutomation extends MobileBy implements Serializable {
346
+
347
+ protected ByWindowsAutomation (String locatorString ) {
348
+ super (MobileSelector .WINDOWS_UI_AUTOMATION , locatorString );
349
+ }
350
+
351
+ /**
352
+ * @throws WebDriverException when current session doesn't support the given selector or when
353
+ * value of the selector is not consistent.
354
+ * @throws IllegalArgumentException when it is impossible to find something on the given
355
+ * {@link SearchContext} instance
356
+ */
357
+ @ SuppressWarnings ("unchecked" )
358
+ @ Override public List <WebElement > findElements (SearchContext context ) {
359
+ Class <?> contextClass = context .getClass ();
360
+
361
+ if (FindsByWindowsAutomation .class .isAssignableFrom (contextClass )) {
362
+ return FindsByWindowsAutomation .class .cast (context )
363
+ .findElementsByWindowsUIAutomation (getLocatorString ());
364
+ }
365
+
366
+ if (FindsByFluentSelector .class .isAssignableFrom (context .getClass ())) {
367
+ return super .findElements (context );
368
+ }
369
+
370
+ throw formIllegalArgumentException (contextClass , FindsByWindowsAutomation .class ,
371
+ FindsByFluentSelector .class );
372
+ }
373
+
374
+ /**
375
+ * @throws WebDriverException when current session doesn't support the given selector or when
376
+ * value of the selector is not consistent.
377
+ * @throws IllegalArgumentException when it is impossible to find something on the given
378
+ * {@link SearchContext} instance
379
+ */
380
+ @ Override public WebElement findElement (SearchContext context ) {
381
+ Class <?> contextClass = context .getClass ();
382
+
383
+ if (FindsByWindowsAutomation .class .isAssignableFrom (contextClass )) {
384
+ return FindsByWindowsAutomation .class .cast (context )
385
+ .findElementByWindowsUIAutomation (getLocatorString ());
386
+ }
387
+
388
+ if (FindsByFluentSelector .class .isAssignableFrom (context .getClass ())) {
389
+ return super .findElement (context );
390
+ }
391
+
392
+ throw formIllegalArgumentException (contextClass , FindsByIosNSPredicate .class ,
393
+ FindsByWindowsAutomation .class );
394
+ }
395
+ }
344
396
}
345
397
346
398
0 commit comments