Skip to content

Commit 4c92e82

Browse files
The refactoring of widget tests: missed parameters of the OverrideWidget are handled now
1 parent 1ceec6a commit 4c92e82

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/main/java/io/appium/java_client/pagefactory/OverrideWidgetReader.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static io.appium.java_client.pagefactory.WidgetConstructorUtil.findConvenientConstructor;
2020
import static io.appium.java_client.remote.MobilePlatform.ANDROID;
2121
import static io.appium.java_client.remote.MobilePlatform.IOS;
22+
import static io.appium.java_client.remote.MobilePlatform.WINDOWS;
2223

2324
import io.appium.java_client.pagefactory.bys.ContentType;
2425
import io.appium.java_client.remote.AutomationName;
@@ -35,6 +36,8 @@ class OverrideWidgetReader {
3536
private static final String ANDROID_UI_AUTOMATOR = "androidUIAutomator";
3637
private static final String IOS_UI_AUTOMATION = "iOSUIAutomation";
3738
private static final String SELENDROID = "selendroid";
39+
private static final String IOS_XCUIT_AUTOMATION = "iOSXCUITAutomation";
40+
private static final String WINDOWS_AUTOMATION = "windowsAutomation";
3841

3942
@SuppressWarnings("unchecked")
4043
private static Class<? extends Widget> getConvenientClass(Class<? extends Widget> declaredClass,
@@ -83,10 +86,19 @@ static Class<? extends Widget> getMobileNativeWidgetClass(Class<? extends Widget
8386
return getConvenientClass(declaredClass, annotatedElement, ANDROID_UI_AUTOMATOR);
8487
}
8588

89+
if (IOS.equalsIgnoreCase(transformedPlatform) && AutomationName.IOS_XCUI_TEST
90+
.equalsIgnoreCase(transformedAutomation)) {
91+
return getConvenientClass(declaredClass, annotatedElement, IOS_XCUIT_AUTOMATION);
92+
}
93+
8694
if (IOS.equalsIgnoreCase(transformedPlatform)) {
8795
return getConvenientClass(declaredClass, annotatedElement, IOS_UI_AUTOMATION);
8896
}
8997

98+
if (WINDOWS.equalsIgnoreCase(transformedPlatform)) {
99+
return getConvenientClass(declaredClass, annotatedElement, WINDOWS_AUTOMATION);
100+
}
101+
90102
return getDefaultOrHTMLWidgetClass(declaredClass, annotatedElement);
91103
}
92104

src/main/java/io/appium/java_client/pagefactory/WidgetByBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static io.appium.java_client.pagefactory.OverrideWidgetReader.getDefaultOrHTMLWidgetClass;
2020
import static io.appium.java_client.pagefactory.OverrideWidgetReader.getMobileNativeWidgetClass;
21+
import static java.util.Optional.ofNullable;
2122

2223
import org.openqa.selenium.By;
2324

@@ -26,7 +27,6 @@
2627
import java.lang.reflect.ParameterizedType;
2728
import java.lang.reflect.Type;
2829
import java.util.List;
29-
import java.util.Optional;
3030

3131
public class WidgetByBuilder extends DefaultElementByBuilder {
3232

@@ -92,12 +92,12 @@ private By getByFromDeclaredClass(WhatIsNeeded whatIsNeeded) {
9292
}
9393

9494
@Override protected By buildDefaultBy() {
95-
return Optional.ofNullable(super.buildDefaultBy())
95+
return ofNullable(super.buildDefaultBy())
9696
.orElse(getByFromDeclaredClass(WhatIsNeeded.DEFAULT_OR_HTML));
9797
}
9898

9999
@Override protected By buildMobileNativeBy() {
100-
return Optional.ofNullable(super.buildMobileNativeBy())
100+
return ofNullable(super.buildMobileNativeBy())
101101
.orElse(getByFromDeclaredClass(WhatIsNeeded.MOBILE_NATIVE));
102102
}
103103

0 commit comments

Comments
 (0)