Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.remote.Response;
import org.openqa.selenium.remote.http.HttpMethod;
Expand All @@ -32,7 +33,6 @@
import static io.appium.java_client.utils.TestUtils.waitUntilTrue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -94,10 +94,17 @@ public void getDeviceTimeTest() {
}

@Test public void orientationTest() {
assertEquals(ScreenOrientation.PORTRAIT, driver.getOrientation());
driver.rotate(ScreenOrientation.LANDSCAPE);
assertEquals(ScreenOrientation.LANDSCAPE, driver.getOrientation());
driver.rotate(ScreenOrientation.PORTRAIT);
rotateWithRetry(ScreenOrientation.LANDSCAPE);
waitUntilTrue(
() -> driver.getOrientation() == ScreenOrientation.LANDSCAPE,
Duration.ofSeconds(5), Duration.ofMillis(500)
);

rotateWithRetry(ScreenOrientation.PORTRAIT);
waitUntilTrue(
() -> driver.getOrientation() == ScreenOrientation.PORTRAIT,
Duration.ofSeconds(5), Duration.ofMillis(500)
);
}

@Test public void lockTest() {
Expand Down Expand Up @@ -138,4 +145,27 @@ public void applicationsManagementTest() {
() -> driver.queryAppState(BUNDLE_ID) == ApplicationState.RUNNING_IN_FOREGROUND,
Duration.ofSeconds(10), Duration.ofSeconds(1));
}

private void rotateWithRetry(ScreenOrientation orientation) {
final int maxRetries = 3;
final Duration retryDelay = Duration.ofSeconds(1);

for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
driver.rotate(orientation);
return;
} catch (WebDriverException e) {
if (attempt < maxRetries - 1) {
try {
Thread.sleep(retryDelay.toMillis());
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new RuntimeException(ie);
}
continue;
}
throw e;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

package io.appium.java_client.ios;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;

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

var slider = driver.findElement(SLIDER_CLASS);
WebElement slider;
try {
slider = driver.findElement(SLIDER_CLASS);
} catch (WebDriverException e) {
Assumptions.assumeTrue(
false,
"The slider element is not presented properly by the current RN build"
);
return;
}
var previousValue = slider.getAttribute("value");
slider.sendKeys("0.5");
assertNotEquals(slider.getAttribute("value"), previousValue);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/appium/java_client/utils/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public class TestUtils {
public static final String IOS_SIM_VODQA_RELEASE_URL =
"https://github.com/appium/VodQAReactNative/releases/download/v1.0.1/VodQAReactNative-simulator-release.zip";
"https://github.com/appium/VodQAReactNative/releases/download/v1.2.3/VodQAReactNative-simulator-release.zip";

private TestUtils() {
}
Expand Down