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
All Methods Static Methods Instance Methods Concrete Methods 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.voidsetAndroidCloudDevices()set android devices managed by the cloud service values set at android.capabilties.deviceName with format: device:version eg.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 Detail
-
capabilities
public org.openqa.selenium.remote.DesiredCapabilities capabilities
-
APP_DIR_PATH
public static String APP_DIR_PATH
-
APP_NAME
public static String APP_NAME
-
ANDROID_ENGINE
public static String ANDROID_ENGINE
-
UIAUTOMATOR2
public static String UIAUTOMATOR2
-
ANDROID_INIT
public static boolean ANDROID_INIT
-
ANDROID_HOME
public static String ANDROID_HOME
-
ANDROID_UDID
public static String ANDROID_UDID
-
IS_HYBRID_APP
public static String IS_HYBRID_APP
-
CHROME_VERSION
public static String CHROME_VERSION
-
SYSTEM_PORT
public static int SYSTEM_PORT
-
-
Method Detail
-
withCapability
public AndroidCapability withCapability(org.openqa.selenium.remote.DesiredCapabilities Capabilities)
-
withDevice
public AndroidCapability withDevice(String device)
device: property name from property file. eg. device1, device2- Parameters:
device-- Returns:
-
getCapability
public org.openqa.selenium.remote.DesiredCapabilities getCapability()
-
getAppPath
public String getAppPath()
-
withAndroidCapability
public AndroidCapability 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
public static List<String> getRealDevices(List<String> devices)
gets the name of the first real device connected- Parameters:
devices-- Returns:
-
getAndroidDeviceList
public static List<String> getAndroidDeviceList()
gets the list of android devices including real devices + emulators skips the first item, as it is not a device- Returns:
- device list
-
setSimulator
public void setSimulator()
sets ios device number of devices must be equal or greater than number of threads for parallel run
-
setPort
public void setPort(String deviceName)
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
-
setAndroidCloudDevices
public void setAndroidCloudDevices()
set android devices managed by the cloud service values set at android.capabilties.deviceName with format: device:version eg. android.capabilties.deviceName = "Pixel 8 pro:14, Pixel 8:14, Pixel 7 pro:14:13, Pixel 7:13"
-
printAndroidHelp
public static void printAndroidHelp(Exception e)
-
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
-
-