Skip to content

Commit 7440205

Browse files
test: Replace iOS test app with VodQA
1 parent a9812cb commit 7440205

File tree

4 files changed

+40
-38
lines changed

4 files changed

+40
-38
lines changed

src/e2eIosTest/java/io/appium/java_client/ios/AppIOSTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
package io.appium.java_client.ios;
22

33
import io.appium.java_client.ios.options.XCUITestOptions;
4-
import io.appium.java_client.utils.TestUtils;
54
import org.junit.jupiter.api.BeforeAll;
5+
import org.openqa.selenium.By;
66
import org.openqa.selenium.SessionNotCreatedException;
77

8+
import java.net.MalformedURLException;
9+
import java.net.URL;
810
import java.time.Duration;
911

10-
public class AppIOSTest extends BaseIOSTest {
11-
protected static final String BUNDLE_ID = "io.appium.TestApp";
12+
import static io.appium.java_client.AppiumBy.accessibilityId;
13+
import static io.appium.java_client.AppiumBy.iOSNsPredicateString;
14+
import static io.appium.java_client.utils.TestUtils.IOS_SIM_VODQA_RELEASE_URL;
1215

13-
private static final String TEST_APP_ZIP = TestUtils.resourcePathToAbsolutePath("TestApp.app.zip").toString();
16+
public class AppIOSTest extends BaseIOSTest {
17+
protected static final String BUNDLE_ID = "org.reactjs.native.example.VodQAReactNative";
18+
protected static final By LOGIN_LINK_ID = accessibilityId("login");
19+
protected static final By PASSWORD_EDIT_PREDICATE = iOSNsPredicateString("name == \"password\"");
1420

1521
@BeforeAll
16-
public static void beforeClass() {
22+
public static void beforeClass() throws MalformedURLException {
1723
startAppiumServer();
1824

1925
XCUITestOptions options = new XCUITestOptions()
2026
.setPlatformVersion(PLATFORM_VERSION)
2127
.setDeviceName(DEVICE_NAME)
2228
.setCommandTimeouts(Duration.ofSeconds(240))
23-
.setApp(TEST_APP_ZIP)
29+
.setApp(new URL(IOS_SIM_VODQA_RELEASE_URL))
2430
.enableBiDi()
2531
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT);
2632
if (PREBUILT_WDA_PATH != null) {

src/e2eIosTest/java/io/appium/java_client/ios/BaseIOSTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,18 @@
2222
import org.junit.jupiter.api.AfterAll;
2323

2424
import java.time.Duration;
25+
import java.util.Optional;
2526

2627
@SuppressWarnings("checkstyle:HideUtilityClassConstructor")
2728
public class BaseIOSTest {
2829

2930
protected static AppiumDriverLocalService service;
3031
protected static IOSDriver driver;
3132
protected static final int PORT = 4723;
32-
public static final String DEVICE_NAME = System.getenv("IOS_DEVICE_NAME") != null
33-
? System.getenv("IOS_DEVICE_NAME")
34-
: "iPhone 12";
35-
public static final String PLATFORM_VERSION = System.getenv("IOS_PLATFORM_VERSION") != null
36-
? System.getenv("IOS_PLATFORM_VERSION")
37-
: "14.5";
33+
public static final String DEVICE_NAME = Optional.ofNullable(System.getenv("IOS_DEVICE_NAME"))
34+
.orElse("iPhone 17");
35+
public static final String PLATFORM_VERSION = Optional.ofNullable(System.getenv("IOS_PLATFORM_VERSION"))
36+
.orElse("26.0");
3837
public static final Duration WDA_LAUNCH_TIMEOUT = Duration.ofMinutes(4);
3938
public static final Duration SERVER_START_TIMEOUT = Duration.ofMinutes(3);
4039
protected static String PREBUILT_WDA_PATH = System.getenv("PREBUILT_WDA_PATH");

src/e2eIosTest/java/io/appium/java_client/ios/ClipboardTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public class ClipboardTest extends AppIOSTest {
2525
@Test public void verifySetAndGetClipboardText() {
2626
final String text = "Happy testing";
2727
driver.setClipboardText(text);
28-
assertEquals(driver.getClipboardText(), text);
28+
assertEquals(text, driver.getClipboardText());
2929
}
3030
}

src/e2eIosTest/java/io/appium/java_client/ios/IOSAlertTest.java

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package io.appium.java_client.ios;
1818

19-
import io.appium.java_client.AppiumBy;
2019
import org.apache.commons.lang3.StringUtils;
2120
import org.junit.jupiter.api.AfterEach;
2221
import org.junit.jupiter.api.MethodOrderer;
@@ -35,34 +34,10 @@
3534

3635
@TestMethodOrder(MethodOrderer.MethodName.class)
3736
public class IOSAlertTest extends AppIOSTest {
38-
3937
private static final Duration ALERT_TIMEOUT = Duration.ofSeconds(5);
4038
private static final int CLICK_RETRIES = 2;
41-
private static final String IOS_AUTOMATION_TEXT = "show alert";
42-
4339
private final WebDriverWait waiter = new WebDriverWait(driver, ALERT_TIMEOUT);
4440

45-
private void ensureAlertPresence() {
46-
int retry = 0;
47-
// CI might not be performant enough, so we need to retry
48-
while (true) {
49-
try {
50-
driver.findElement(AppiumBy.accessibilityId(IOS_AUTOMATION_TEXT)).click();
51-
} catch (WebDriverException e) {
52-
// ignore
53-
}
54-
try {
55-
waiter.until(alertIsPresent());
56-
return;
57-
} catch (TimeoutException e) {
58-
retry++;
59-
if (retry >= CLICK_RETRIES) {
60-
throw e;
61-
}
62-
}
63-
}
64-
}
65-
6641
@AfterEach
6742
public void afterEach() {
6843
try {
@@ -97,4 +72,26 @@ public void getAlertTextTest() {
9772
ensureAlertPresence();
9873
assertFalse(StringUtils.isBlank(driver.switchTo().alert().getText()));
9974
}
75+
76+
private void ensureAlertPresence() {
77+
int retry = 0;
78+
// CI might not be performant enough, so we need to retry
79+
while (true) {
80+
try {
81+
driver.findElement(PASSWORD_EDIT_PREDICATE).sendKeys("foo");
82+
driver.findElement(LOGIN_LINK_ID).click();
83+
} catch (WebDriverException e) {
84+
// ignore
85+
}
86+
try {
87+
waiter.until(alertIsPresent());
88+
return;
89+
} catch (TimeoutException e) {
90+
retry++;
91+
if (retry >= CLICK_RETRIES) {
92+
throw e;
93+
}
94+
}
95+
}
96+
}
10097
}

0 commit comments

Comments
 (0)