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,27 +22,30 @@
import io.appium.java_client.remote.AutomationName;
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
import io.appium.java_client.utils.TestUtils;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Platform;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;

import static io.appium.java_client.remote.options.SupportsDeviceNameOption.DEVICE_NAME_OPTION;
import static io.appium.java_client.utils.TestUtils.IOS_SIM_VODQA_RELEASE_URL;
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;
import static org.openqa.selenium.remote.CapabilityType.PLATFORM_NAME;

class StartingAppLocallyIosTest {
private static final String UI_CATALOG_ZIP = TestUtils.resourcePathToAbsolutePath("UICatalog.app.zip").toString();

@Test
void startingIOSAppWithCapabilitiesOnlyTest() {
void startingIOSAppWithCapabilitiesOnlyTest() throws MalformedURLException {
var appUrl = new URL(IOS_SIM_VODQA_RELEASE_URL);
XCUITestOptions options = new XCUITestOptions()
.setPlatformVersion(BaseIOSTest.PLATFORM_VERSION)
.setDeviceName(BaseIOSTest.DEVICE_NAME)
.setApp(UI_CATALOG_ZIP)
.setApp(appUrl)
.setWdaLaunchTimeout(BaseIOSTest.WDA_LAUNCH_TIMEOUT);
IOSDriver driver = new IOSDriver(options);
try {
Expand All @@ -52,19 +55,19 @@ void startingIOSAppWithCapabilitiesOnlyTest() {
assertEquals(Platform.IOS, caps.getPlatformName());
assertNotNull(caps.getDeviceName().orElse(null));
assertEquals(BaseIOSTest.PLATFORM_VERSION, caps.getPlatformVersion().orElse(null));
assertEquals(UI_CATALOG_ZIP, caps.getApp().orElse(null));
assertEquals(appUrl.toString(), caps.getApp().orElse(null));
} finally {
driver.quit();
}
}


@Test
void startingIOSAppWithCapabilitiesAndServiceTest() {
void startingIOSAppWithCapabilitiesAndServiceTest() throws MalformedURLException {
var appUrl = new URL(IOS_SIM_VODQA_RELEASE_URL);
XCUITestOptions options = new XCUITestOptions()
.setPlatformVersion(BaseIOSTest.PLATFORM_VERSION)
.setDeviceName(BaseIOSTest.DEVICE_NAME)
.setApp(UI_CATALOG_ZIP)
.setApp(appUrl)
.setWdaLaunchTimeout(BaseIOSTest.WDA_LAUNCH_TIMEOUT);

AppiumServiceBuilder builder = new AppiumServiceBuilder()
Expand All @@ -75,7 +78,7 @@ void startingIOSAppWithCapabilitiesAndServiceTest() {
IOSDriver driver = new IOSDriver(builder, options);
try {
Capabilities caps = driver.getCapabilities();
assertTrue(caps.getCapability(PLATFORM_NAME)
assertTrue(Objects.requireNonNull(caps.getCapability(PLATFORM_NAME))
.toString().equalsIgnoreCase(MobilePlatform.IOS));
assertNotNull(caps.getCapability(DEVICE_NAME_OPTION));
} finally {
Expand All @@ -84,14 +87,15 @@ void startingIOSAppWithCapabilitiesAndServiceTest() {
}

@Test
void startingIOSAppWithCapabilitiesAndFlagsOnServerSideTest() {
void startingIOSAppWithCapabilitiesAndFlagsOnServerSideTest() throws MalformedURLException {
var appUrl = new URL(IOS_SIM_VODQA_RELEASE_URL);
XCUITestOptions serverOptions = new XCUITestOptions()
.setPlatformVersion(BaseIOSTest.PLATFORM_VERSION)
.setDeviceName(BaseIOSTest.DEVICE_NAME)
.setWdaLaunchTimeout(BaseIOSTest.WDA_LAUNCH_TIMEOUT);

XCUITestOptions clientOptions = new XCUITestOptions()
.setApp(UI_CATALOG_ZIP);
.setApp(appUrl);

AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
Expand Down
Binary file removed src/e2eIosTest/resources/UICatalog.app.zip
Binary file not shown.