Package co.verisoft.fw.perfecto
Class PerfectoUtils
java.lang.Object
co.verisoft.fw.perfecto.PerfectoUtils
Original version url:
https://github.com/qmetry/qaf-perfecto-support/blob/master/src/com/qmetry/qaf/automation/support/perfecto/PerfectoUtils.java
- Since:
- October, 2023
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
static void
executePerfectoCommand
(org.openqa.selenium.remote.RemoteWebDriver driver, String command, Map<String, String> params) static String
getAppInfo
(org.openqa.selenium.remote.RemoteWebDriver driver, String property) static String
getCurrentContext
(org.openqa.selenium.remote.RemoteWebDriver driver) static String
getDeviceLocation
(org.openqa.selenium.remote.RemoteWebDriver driver) getDeviceProperties
(org.openqa.selenium.Capabilities capabilities) static String
getTimezone
(org.openqa.selenium.remote.RemoteWebDriver driver) static void
goToHomeScreen
(org.openqa.selenium.remote.RemoteWebDriver driver) static void
hideKeyboard
(org.openqa.selenium.remote.RemoteWebDriver driver) Hides the virtual keyboard display.static void
installApp
(String filePath, org.openqa.selenium.remote.RemoteWebDriver d, boolean shouldInstrument) static boolean
isDesktopBrowser
(org.openqa.selenium.Capabilities caps) static boolean
isDevice
(org.openqa.selenium.Capabilities caps) static boolean
isDevice
(org.openqa.selenium.remote.RemoteWebDriver driver) Checks if is device.static void
lockDevice
(org.openqa.selenium.remote.RemoteWebDriver driver, int sec) static void
Clicks on a single or sequence of physical device keys.static void
resetLocation
(org.openqa.selenium.remote.RemoteWebDriver driver) static void
resetTimezone
(org.openqa.selenium.remote.RemoteWebDriver driver) static void
rotateDevice
(org.openqa.selenium.remote.RemoteWebDriver driver, String restValue, String by) Rotates the device to landscape, portrait, or its next state.static void
setLocation
(org.openqa.selenium.remote.RemoteWebDriver driver, String location, String by) static void
setTimezone
(org.openqa.selenium.remote.RemoteWebDriver driver, String timezone) static void
static void
Performs the swipe gesture according to the start and end coordinates.static void
switchToContext
(org.openqa.selenium.remote.RemoteWebDriver driver, String context) static void
takeScreenshot
(org.openqa.selenium.remote.RemoteWebDriver driver, String repositoryPath, boolean shouldSave) static void
Performs the touch gesture according to the point coordinates.static void
uninstallAllApps
(org.openqa.selenium.remote.RemoteWebDriver driver) static void
uninstallApp
(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by) static void
uploadMedia
(String host, String user, String password, byte[] content, String repositoryKey) Uploads content to the media repository.static void
Uploads a file to the media repository.static void
Uploads a file to the media repository.static void
waitForPresentImageVisual
(org.openqa.selenium.remote.RemoteWebDriver driver, String image, int seconds) static void
waitForPresentTextVisual
(org.openqa.selenium.remote.RemoteWebDriver driver, String text, int seconds)
-
Constructor Details
-
PerfectoUtils
public PerfectoUtils()
-
-
Method Details
-
uploadMedia
public static void uploadMedia(String host, String user, String password, String path, String repositoryKey) throws IOException Uploads a file to the media repository. Example: uploadMedia("demo.perfectomobile.com", "[email protected]", "123456", "C:\\test\\ApiDemos.apk", "PRIVATE:apps/ApiDemos.apk");- Throws:
IOException
-
uploadMedia
public static void uploadMedia(String host, String user, String password, URL mediaURL, String repositoryKey) throws IOException Uploads a file to the media repository. Example: URL url = new URL( "http://file.appsapk.com/wp-content/uploads/downloads/Sudoku%20Free.apk") ; uploadMedia("demo.perfectomobile.com", "[email protected]", "123456", url, "PRIVATE:apps/ApiDemos.apk");- Throws:
IOException
-
uploadMedia
public static void uploadMedia(String host, String user, String password, byte[] content, String repositoryKey) throws UnsupportedEncodingException, MalformedURLException, IOException Uploads content to the media repository. Example: uploadMedia("demo.perfectomobile.com", "[email protected]", "123456", content, "PRIVATE:apps/ApiDemos.apk"); -
installApp
public static void installApp(String filePath, org.openqa.selenium.remote.RemoteWebDriver d, boolean shouldInstrument) -
startApp
-
closeApp
-
cleanApp
-
uninstallApp
-
uninstallAllApps
public static void uninstallAllApps(org.openqa.selenium.remote.RemoteWebDriver driver) -
getAppInfo
-
switchToContext
public static void switchToContext(org.openqa.selenium.remote.RemoteWebDriver driver, String context) -
waitForPresentTextVisual
public static void waitForPresentTextVisual(org.openqa.selenium.remote.RemoteWebDriver driver, String text, int seconds) -
waitForPresentImageVisual
public static void waitForPresentImageVisual(org.openqa.selenium.remote.RemoteWebDriver driver, String image, int seconds) -
getCurrentContext
- Parameters:
driver
-- Returns:
- the current context - "NATIVE_APP", "WEBVIEW", "VISUAL"
-
pressKey
Clicks on a single or sequence of physical device keys. Mouse-over the device keys to identify them, then input into the Keys parameter according to the required syntax.Common keys include: LEFT, RIGHT, UP, DOWN, OK, BACK, MENU, VOL_UP, VOL_DOWN, CAMERA, CLEAR.
The listed keys are not necessarily supported by all devices. The available keys depend on the device.
- Parameters:
driver
- the RemoteWebDriverkeySequence
- the single or sequence of keys to click
-
swipe
public static void swipe(org.openqa.selenium.remote.RemoteWebDriver driver, String start, String end) Performs the swipe gesture according to the start and end coordinates.Example swipe left:
start: 60%,50% end: 10%,50%- Parameters:
driver
- the RemoteWebDriverstart
- write in format of x,y. can be in pixels or percentage(recommended).end
- write in format of x,y. can be in pixels or percentage(recommended).
-
touch
Performs the touch gesture according to the point coordinates.- Parameters:
driver
- the RemoteWebDriverpoint
- write in format of x,y. can be in pixels or percentage(recommended).
-
hideKeyboard
public static void hideKeyboard(org.openqa.selenium.remote.RemoteWebDriver driver) Hides the virtual keyboard display.- Parameters:
driver
- the RemoteWebDriver
-
rotateDevice
public static void rotateDevice(org.openqa.selenium.remote.RemoteWebDriver driver, String restValue, String by) Rotates the device to landscape, portrait, or its next state.- Parameters:
driver
- the RemoteWebDriverrestValue
- the "next" operation, or the "landscape" or "portrait" state.by
- the "state" or "operation"
-
setLocation
-
getDeviceLocation
-
resetLocation
public static void resetLocation(org.openqa.selenium.remote.RemoteWebDriver driver) -
goToHomeScreen
public static void goToHomeScreen(org.openqa.selenium.remote.RemoteWebDriver driver) -
lockDevice
public static void lockDevice(org.openqa.selenium.remote.RemoteWebDriver driver, int sec) -
setTimezone
-
getTimezone
-
resetTimezone
public static void resetTimezone(org.openqa.selenium.remote.RemoteWebDriver driver) -
takeScreenshot
public static void takeScreenshot(org.openqa.selenium.remote.RemoteWebDriver driver, String repositoryPath, boolean shouldSave) -
executePerfectoCommand
-
isDevice
public static boolean isDevice(org.openqa.selenium.Capabilities caps) -
isDesktopBrowser
public static boolean isDesktopBrowser(org.openqa.selenium.Capabilities caps) -
isDevice
public static boolean isDevice(org.openqa.selenium.remote.RemoteWebDriver driver) Checks if is device.TODO: complete me
- Parameters:
driver
- the driver- Returns:
- true, if is device
-
getDeviceProperties
-