com.github.arachnidium.model.mobile.MobileFactory Maven / Gradle / Ivy
package com.github.arachnidium.model.mobile;
import io.appium.java_client.remote.MobileCapabilityType;
import java.net.URL;
import com.github.arachnidium.util.configuration.Configuration;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import com.github.arachnidium.core.ScreenManager;
import com.github.arachnidium.core.settings.AlertIsPresentTimeOut;
import com.github.arachnidium.core.settings.CapabilitySettings;
import com.github.arachnidium.core.settings.ChromeDriverServerBin;
import com.github.arachnidium.core.settings.HandleWaitingTimeOut;
import com.github.arachnidium.core.settings.IEDriverServerBin;
import com.github.arachnidium.core.settings.PhantomJSDriverBin;
import com.github.arachnidium.core.settings.ScreenShots;
import com.github.arachnidium.core.settings.WebDriverSettings;
import com.github.arachnidium.core.settings.WebDriverTimeOuts;
import com.github.arachnidium.core.settings.supported.ESupportedDrivers;
import com.github.arachnidium.model.common.Application;
import com.github.arachnidium.model.common.DefaultApplicationFactory;
public final class MobileFactory extends DefaultApplicationFactory {
private static WebDriverDesignationChecker objectWhichChecksWebDriver = givenWebDriverDesignation -> {
if (!givenWebDriverDesignation.isForMobileApp()){
throw new IllegalArgumentException(givenWebDriverDesignation.toString() + " is not for mobile "
+ "app launching!");
}
};
/**
* Common method that creates an instance of a mobile application using
* default configuration It is important: URL to remote server and
* capabilities should be defined in default configuration
*
* Attention, please!
* {@link ESupportedDrivers#ANDROID_APP} or {@link ESupportedDrivers#IOS_APP} should
* be defined in the {@link Configuration#byDefault}.
{@link Capabilities} should be
* defined. Required capabilities:
* - {@link MobileCapabilityType#APP}
* - {@link MobileCapabilityType#PLATFORM_VERSION} - for {@link ESupportedDrivers#IOS_APP}
* - {@link MobileCapabilityType#DEVICE_NAME}
*
* @see
* {@link Configuration}
* {@link WebDriverSettings}
* {@link CapabilitySettings}
* {@link WebDriverTimeOuts}
* {@link HandleWaitingTimeOut}
* {@link AlertIsPresentTimeOut}
* {@link ChromeDriverServerBin}
* {@link IEDriverServerBin}
* {@link PhantomJSDriverBin}
* {@link ScreenShots}
*/
public static > T getApplication(
Class appClass) {
return getApplication(appClass, Configuration.byDefault);
}
/**
* Common method that creates an instance of a mobile application using
* defined address of remote server and capabilities.
*
* Available supported {@link WebDriver} designations:
* - {@link ESupportedDrivers#ANDROID_APP}
* - {@link ESupportedDrivers#IOS_APP}
*
* These capabilities should be defined:
* - {@link MobileCapabilityType#APP}
* - {@link MobileCapabilityType#PLATFORM_VERSION} - for {@link ESupportedDrivers#IOS_APP}
* - {@link MobileCapabilityType#DEVICE_NAME}
*
*/
public static > T getApplication(
Class appClass, ESupportedDrivers supportedDriver,
Capabilities capabilities, URL remoteAddress) {
return getApplication(ScreenManager.class, appClass,
supportedDriver, capabilities, remoteAddress,
new MobileApplicationInterceptor(), objectWhichChecksWebDriver);
}
/**
* Common method that creates an instance of a mobile application using
* defined configuration It is important: URL to remote server and
* capabilities should be defined in configuration
*
*
* Attention, please!
* {@link ESupportedDrivers#ANDROID_APP} or {@link ESupportedDrivers#IOS_APP} should
* be defined in the given {@link Configuration}.
{@link Capabilities} should be
* defined. Required capabilities:
* - {@link MobileCapabilityType#APP}
* - {@link MobileCapabilityType#PLATFORM_VERSION} - for {@link ESupportedDrivers#IOS_APP}
* - {@link MobileCapabilityType#DEVICE_NAME}
*
* @see
* {@link Configuration}
* {@link WebDriverSettings}
* {@link CapabilitySettings}
* {@link WebDriverTimeOuts}
* {@link HandleWaitingTimeOut}
* {@link AlertIsPresentTimeOut}
* {@link ChromeDriverServerBin}
* {@link IEDriverServerBin}
* {@link PhantomJSDriverBin}
* {@link ScreenShots}
*/
public static > T getApplication(
Class appClass, Configuration configuration) {
T result = getApplication(ScreenManager.class, appClass,
configuration, new MobileApplicationInterceptor(), objectWhichChecksWebDriver);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy