Skip to content

Commit d029bc9

Browse files
authored
chore: deprecate Windows UIAutomation selector (#1562)
1 parent e5fa9de commit d029bc9

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed

src/main/java/io/appium/java_client/AppiumBy.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,6 @@ public static By iOSNsPredicateString(final String iOSNsPredicateString) {
164164
return new ByIosNsPredicate(iOSNsPredicateString);
165165
}
166166

167-
/**
168-
* The Windows UIAutomation selector.
169-
* @param windowsAutomation The element name in the Windows UIAutomation selector
170-
* @return an instance of {@link AppiumBy.ByWindowsAutomation}
171-
*/
172-
public static By windowsAutomation(final String windowsAutomation) {
173-
return new ByWindowsAutomation(windowsAutomation);
174-
}
175-
176167
public static class ByAccessibilityId extends AppiumBy implements Serializable {
177168

178169
public ByAccessibilityId(String accessibilityId) {
@@ -242,13 +233,6 @@ protected ByIosNsPredicate(String locatorString) {
242233
super("-ios predicate string", locatorString, "iOSNsPredicate");
243234
}
244235
}
245-
246-
public static class ByWindowsAutomation extends AppiumBy implements Serializable {
247-
248-
protected ByWindowsAutomation(String locatorString) {
249-
super("-windows uiautomation", locatorString, "windowsAutomation");
250-
}
251-
}
252236
}
253237

254238

src/main/java/io/appium/java_client/MobileBy.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.appium.java_client;
1818

19+
import java.io.Serializable;
20+
1921
import org.openqa.selenium.By;
2022

2123
/**
@@ -107,6 +109,17 @@ public static By iOSNsPredicateString(final String iOSNsPredicateString) {
107109
return new ByIosNsPredicate(iOSNsPredicateString);
108110
}
109111

112+
/**
113+
* The Windows UIAutomation selector.
114+
* @deprecated Not supported on the server side.
115+
* @param windowsAutomation The element name in the Windows UIAutomation selector
116+
* @return an instance of {@link MobileBy.ByWindowsAutomation}
117+
*/
118+
@Deprecated
119+
public static By windowsAutomation(final String windowsAutomation) {
120+
return new ByWindowsAutomation(windowsAutomation);
121+
}
122+
110123
/**
111124
* This locator strategy is available in Espresso Driver mode.
112125
* @deprecated Use {@link AppiumBy#androidViewTag(String)} instead.
@@ -261,13 +274,17 @@ protected ByIosNsPredicate(String locatorString) {
261274

262275
/**
263276
* The Windows UIAutomation selector.
264-
* @deprecated Use {@link AppiumBy.ByWindowsAutomation} instead.
277+
* @deprecated Not supported on the server side.
265278
*/
266279
@Deprecated
267-
public static class ByWindowsAutomation extends AppiumBy.ByWindowsAutomation {
280+
public static class ByWindowsAutomation extends MobileBy implements Serializable {
268281

269282
protected ByWindowsAutomation(String locatorString) {
270-
super(locatorString);
283+
super("-windows uiautomation", locatorString, "windowsAutomation");
284+
}
285+
286+
@Override public String toString() {
287+
return "By.windowsAutomation: " + getRemoteParameters().value();
271288
}
272289
}
273290

src/main/java/io/appium/java_client/pagefactory/bys/builder/Strategies.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616

1717
package io.appium.java_client.pagefactory.bys.builder;
1818

19-
import io.appium.java_client.AppiumBy;
20-
import io.appium.java_client.pagefactory.AndroidBy;
21-
import io.appium.java_client.pagefactory.AndroidFindBy;
22-
23-
import org.openqa.selenium.By;
24-
2519
import java.lang.annotation.Annotation;
2620
import java.lang.reflect.InvocationTargetException;
2721
import java.lang.reflect.Method;
2822
import java.util.ArrayList;
2923
import java.util.List;
3024

25+
import org.openqa.selenium.By;
26+
27+
import io.appium.java_client.AppiumBy;
28+
import io.appium.java_client.MobileBy;
29+
import io.appium.java_client.pagefactory.AndroidBy;
30+
import io.appium.java_client.pagefactory.AndroidFindBy;
31+
3132
enum Strategies {
3233
BYUIAUTOMATOR("uiAutomator") {
3334
@Override By getBy(Annotation annotation) {
@@ -84,10 +85,14 @@ enum Strategies {
8485
.partialLinkText(getValue(annotation, this));
8586
}
8687
},
88+
/**
89+
* The Windows UIAutomation strategy.
90+
* @deprecated Not supported on the server side.
91+
*/
92+
@Deprecated
8793
BYWINDOWSAUTOMATION("windowsAutomation") {
8894
@Override By getBy(Annotation annotation) {
89-
return AppiumBy
90-
.windowsAutomation(getValue(annotation, this));
95+
return MobileBy.windowsAutomation(getValue(annotation, this));
9196
}
9297
},
9398
BY_CLASS_CHAIN("iOSClassChain") {

src/test/java/io/appium/java_client/pagefactory_tests/widget/tests/windows/WindowsWidgetTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.appium.java_client.pagefactory_tests.widget.tests.windows;
22

3-
import static io.appium.java_client.AppiumBy.windowsAutomation;
3+
import static io.appium.java_client.MobileBy.windowsAutomation;
44
import static io.appium.java_client.pagefactory_tests.widget.tests.windows.AnnotatedWindowsWidget.WINDOWS_ROOT_WIDGET_LOCATOR;
55
import static io.appium.java_client.pagefactory_tests.widget.tests.windows.DefaultWindowsWidget.WINDOWS_SUB_WIDGET_LOCATOR;
66
import static io.appium.java_client.pagefactory_tests.widget.tests.windows.WindowsApp.WINDOWS_DEFAULT_WIDGET_LOCATOR;

0 commit comments

Comments
 (0)