Class AndroidCapability
java.lang.Object
core.uiCore.driverProperties.capabilities.AndroidCapability
public class AndroidCapability extends Object
- Author:
- ehsan.matean
-
Field Summary
Fields Modifier and Type Field Description static StringANDROID_ENGINEstatic StringANDROID_HOMEstatic booleanANDROID_INITstatic StringANDROID_UDIDstatic StringAPP_DIR_PATHstatic StringAPP_NAMEorg.openqa.selenium.remote.DesiredCapabilitiescapabilitiesstatic StringCHROME_VERSIONstatic StringIS_HYBRID_APPList<String>simulatorListstatic intSYSTEM_PORTstatic StringUIAUTOMATOR2 -
Constructor Summary
Constructors Constructor Description AndroidCapability() -
Method Summary
Modifier and Type Method Description static List<String>getAndroidDeviceList()gets the list of android devices including real devices + emulators skips the first item, as it is not a deviceList<String>getAndroidRealDeviceList()StringgetAppPath()org.openqa.selenium.remote.DesiredCapabilitiesgetCapability()static List<String>getRealDevices(List<String> devices)gets the name of the first real device connectedbooleanisRealDeviceConnected()if adb device contains emulator, Then its an emulator otherwise, its a connected real devicestatic voidprintAndroidHelp(Exception e)static voidrestartAdb()org.openqa.selenium.remote.DesiredCapabilitiessetAndroidCapabilties()set capabilties with prefix android.capabilties.voidsetAndroidDevice()sets device by following strategy: if device is connected, selects device if emulator is not specified with "withDevice1() or with Device2() function, select device 1 by default from properties else select emulator from properties specified in panel config pagestatic voidsetAndroidHome()sets the value for android home based on its default location sets android home based on user.home location on mac checks if the generated android home location exists, if true, adds to android.home config valuevoidsetChromeDriver()download chrome driver if hybrid app is enabled if Version is LATEST, download latest driver unless set in configvoidsetPort(String deviceName)if device has port assigned, use assigned port else generate new port numbervoidsetRealDevices()sets real devicevoidsetSimulator()sets ios device number of devices must be equal or greater than number of threads for parallel runvoidsetSingleSignIn()runs subsequent tests without restarting the app removes the need to sign in on every test if tests fail, it will restart the appstatic voiduninstallUiAutomator2()uninstalls the uiautomator2 server only runs the first time android test is run a device or emulator must be connectedAndroidCapabilitywithAndroidCapability()sets android capabilities values are from maven or properties file maven has higher priority than propertiesAndroidCapabilitywithCapability(org.openqa.selenium.remote.DesiredCapabilities Capabilities)AndroidCapabilitywithDevice(String device)device: property name from property file.
-
Field Details
-
capabilities
public org.openqa.selenium.remote.DesiredCapabilities capabilities -
APP_DIR_PATH
-
APP_NAME
-
ANDROID_ENGINE
-
UIAUTOMATOR2
-
ANDROID_INIT
public static boolean ANDROID_INIT -
ANDROID_HOME
-
ANDROID_UDID
-
IS_HYBRID_APP
-
CHROME_VERSION
-
simulatorList
-
SYSTEM_PORT
public static int SYSTEM_PORT
-
-
Constructor Details
-
AndroidCapability
public AndroidCapability()
-
-
Method Details
-
withCapability
public AndroidCapability withCapability(org.openqa.selenium.remote.DesiredCapabilities Capabilities) -
withDevice
device: property name from property file. eg. device1, device2- Parameters:
device-- Returns:
-
getCapability
public org.openqa.selenium.remote.DesiredCapabilities getCapability() -
getAppPath
-
withAndroidCapability
sets android capabilities values are from maven or properties file maven has higher priority than properties- Returns:
-
setAndroidCapabilties
public org.openqa.selenium.remote.DesiredCapabilities setAndroidCapabilties()set capabilties with prefix android.capabilties. eg. android.capabilties.fullReset="false iterates through all property values with such prefix And adds them to android desired capabilities- Returns:
-
setChromeDriver
public void setChromeDriver()download chrome driver if hybrid app is enabled if Version is LATEST, download latest driver unless set in config -
setSingleSignIn
public void setSingleSignIn()runs subsequent tests without restarting the app removes the need to sign in on every test if tests fail, it will restart the app -
isRealDeviceConnected
public boolean isRealDeviceConnected()if adb device contains emulator, Then its an emulator otherwise, its a connected real device- Parameters:
devices-- Returns:
-
getRealDevices
gets the name of the first real device connected- Parameters:
devices-- Returns:
-
getAndroidDeviceList
gets the list of android devices including real devices + emulators skips the first item, as it is not a device- Returns:
- device list
-
getAndroidRealDeviceList
-
setSimulator
public void setSimulator()sets ios device number of devices must be equal or greater than number of threads for parallel run -
setPort
if device has port assigned, use assigned port else generate new port number- Parameters:
deviceName-
-
restartAdb
public static void restartAdb() -
uninstallUiAutomator2
public static void uninstallUiAutomator2()uninstalls the uiautomator2 server only runs the first time android test is run a device or emulator must be connected -
setRealDevices
public void setRealDevices()sets real device -
setAndroidDevice
public void setAndroidDevice()sets device by following strategy: if device is connected, selects device if emulator is not specified with "withDevice1() or with Device2() function, select device 1 by default from properties else select emulator from properties specified in panel config page -
printAndroidHelp
-
setAndroidHome
public static void setAndroidHome()sets the value for android home based on its default location sets android home based on user.home location on mac checks if the generated android home location exists, if true, adds to android.home config value
-