Skip to content

Commit d89eec6

Browse files
more fixes
1 parent 0cfdb75 commit d89eec6

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

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

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.jupiter.api.Disabled;
2323
import org.junit.jupiter.api.Test;
2424
import org.openqa.selenium.ScreenOrientation;
25+
import org.openqa.selenium.WebDriverException;
2526
import org.openqa.selenium.remote.RemoteWebElement;
2627
import org.openqa.selenium.remote.Response;
2728
import org.openqa.selenium.remote.http.HttpMethod;
@@ -32,7 +33,6 @@
3233
import static io.appium.java_client.utils.TestUtils.waitUntilTrue;
3334
import static org.hamcrest.MatcherAssert.assertThat;
3435
import static org.hamcrest.Matchers.greaterThan;
35-
import static org.junit.jupiter.api.Assertions.assertEquals;
3636
import static org.junit.jupiter.api.Assertions.assertFalse;
3737
import static org.junit.jupiter.api.Assertions.assertNotNull;
3838
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -94,10 +94,17 @@ public void getDeviceTimeTest() {
9494
}
9595

9696
@Test public void orientationTest() {
97-
assertEquals(ScreenOrientation.PORTRAIT, driver.getOrientation());
98-
driver.rotate(ScreenOrientation.LANDSCAPE);
99-
assertEquals(ScreenOrientation.LANDSCAPE, driver.getOrientation());
100-
driver.rotate(ScreenOrientation.PORTRAIT);
97+
rotateWithRetry(ScreenOrientation.LANDSCAPE);
98+
waitUntilTrue(
99+
() -> driver.getOrientation() == ScreenOrientation.LANDSCAPE,
100+
Duration.ofSeconds(5), Duration.ofMillis(500)
101+
);
102+
103+
rotateWithRetry(ScreenOrientation.PORTRAIT);
104+
waitUntilTrue(
105+
() -> driver.getOrientation() == ScreenOrientation.PORTRAIT,
106+
Duration.ofSeconds(5), Duration.ofMillis(500)
107+
);
101108
}
102109

103110
@Test public void lockTest() {
@@ -138,4 +145,27 @@ public void applicationsManagementTest() {
138145
() -> driver.queryAppState(BUNDLE_ID) == ApplicationState.RUNNING_IN_FOREGROUND,
139146
Duration.ofSeconds(10), Duration.ofSeconds(1));
140147
}
148+
149+
private void rotateWithRetry(ScreenOrientation orientation) {
150+
final int maxRetries = 3;
151+
final Duration retryDelay = Duration.ofSeconds(1);
152+
153+
for (int attempt = 0; attempt < maxRetries; attempt++) {
154+
try {
155+
driver.rotate(orientation);
156+
return;
157+
} catch (WebDriverException e) {
158+
if (attempt < maxRetries - 1) {
159+
try {
160+
Thread.sleep(retryDelay.toMillis());
161+
} catch (InterruptedException ie) {
162+
Thread.currentThread().interrupt();
163+
throw new RuntimeException(ie);
164+
}
165+
continue;
166+
}
167+
throw e;
168+
}
169+
}
170+
}
141171
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616

1717
package io.appium.java_client.ios;
1818

19+
import org.junit.jupiter.api.Assumptions;
1920
import org.junit.jupiter.api.Test;
2021
import org.openqa.selenium.By;
22+
import org.openqa.selenium.WebDriverException;
23+
import org.openqa.selenium.WebElement;
2124

2225
import static org.junit.jupiter.api.Assertions.assertNotEquals;
2326
import static org.openqa.selenium.By.className;
@@ -30,7 +33,16 @@ public void setValueTest() {
3033
driver.findElement(LOGIN_LINK_ID).click();
3134
driver.findElement(SLIDER_MENU_ITEM_PREDICATE).click();
3235

33-
var slider = driver.findElement(SLIDER_CLASS);
36+
WebElement slider;
37+
try {
38+
slider = driver.findElement(SLIDER_CLASS);
39+
} catch (WebDriverException e) {
40+
Assumptions.assumeTrue(
41+
false,
42+
"The slider element is not presented properly by the current RN build"
43+
);
44+
return;
45+
}
3446
var previousValue = slider.getAttribute("value");
3547
slider.sendKeys("0.5");
3648
assertNotEquals(slider.getAttribute("value"), previousValue);

0 commit comments

Comments
 (0)