Package co.verisoft.fw.perfecto
Class PerfectoUtils
- java.lang.Object
-
- co.verisoft.fw.perfecto.PerfectoUtils
-
public class PerfectoUtils extends Object
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 Constructor Description PerfectoUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)static voidcloseApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)static voidexecutePerfectoCommand(org.openqa.selenium.remote.RemoteWebDriver driver, String command, Map<String,String> params)static StringgetAppInfo(org.openqa.selenium.remote.RemoteWebDriver driver, String property)static StringgetCurrentContext(org.openqa.selenium.remote.RemoteWebDriver driver)static StringgetDeviceLocation(org.openqa.selenium.remote.RemoteWebDriver driver)static Map<String,Object>getDeviceProperties(org.openqa.selenium.Capabilities capabilities)static StringgetTimezone(org.openqa.selenium.remote.RemoteWebDriver driver)static voidgoToHomeScreen(org.openqa.selenium.remote.RemoteWebDriver driver)static voidhideKeyboard(org.openqa.selenium.remote.RemoteWebDriver driver)Hides the virtual keyboard display.static voidinstallApp(String filePath, org.openqa.selenium.remote.RemoteWebDriver d, boolean shouldInstrument)static booleanisDesktopBrowser(org.openqa.selenium.Capabilities caps)static booleanisDevice(org.openqa.selenium.Capabilities caps)static booleanisDevice(org.openqa.selenium.remote.RemoteWebDriver driver)Checks if is device.static voidlockDevice(org.openqa.selenium.remote.RemoteWebDriver driver, int sec)static voidpressKey(org.openqa.selenium.remote.RemoteWebDriver driver, String keySequence)Clicks on a single or sequence of physical device keys.static voidresetLocation(org.openqa.selenium.remote.RemoteWebDriver driver)static voidresetTimezone(org.openqa.selenium.remote.RemoteWebDriver driver)static voidrotateDevice(org.openqa.selenium.remote.RemoteWebDriver driver, String restValue, String by)Rotates the device to landscape, portrait, or its next state.static voidsetLocation(org.openqa.selenium.remote.RemoteWebDriver driver, String location, String by)static voidsetTimezone(org.openqa.selenium.remote.RemoteWebDriver driver, String timezone)static voidstartApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)static voidswipe(org.openqa.selenium.remote.RemoteWebDriver driver, String start, String end)Performs the swipe gesture according to the start and end coordinates.static voidswitchToContext(org.openqa.selenium.remote.RemoteWebDriver driver, String context)static voidtakeScreenshot(org.openqa.selenium.remote.RemoteWebDriver driver, String repositoryPath, boolean shouldSave)static voidtouch(org.openqa.selenium.remote.RemoteWebDriver driver, String point)Performs the touch gesture according to the point coordinates.static voiduninstallAllApps(org.openqa.selenium.remote.RemoteWebDriver driver)static voiduninstallApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)static voiduploadMedia(String host, String user, String password, byte[] content, String repositoryKey)Uploads content to the media repository.static voiduploadMedia(String host, String user, String password, String path, String repositoryKey)Uploads a file to the media repository.static voiduploadMedia(String host, String user, String password, URL mediaURL, String repositoryKey)Uploads a file to the media repository.static voidwaitForPresentImageVisual(org.openqa.selenium.remote.RemoteWebDriver driver, String image, int seconds)static voidwaitForPresentTextVisual(org.openqa.selenium.remote.RemoteWebDriver driver, String text, int seconds)
-
-
-
Method Detail
-
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", "john@perfectomobile.com", "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", "john@perfectomobile.com", "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", "john@perfectomobile.com", "123456", content, "PRIVATE:apps/ApiDemos.apk");
-
installApp
public static void installApp(String filePath, org.openqa.selenium.remote.RemoteWebDriver d, boolean shouldInstrument)
-
startApp
public static void startApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)
-
closeApp
public static void closeApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)
-
cleanApp
public static void cleanApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)
-
uninstallApp
public static void uninstallApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)
-
uninstallAllApps
public static void uninstallAllApps(org.openqa.selenium.remote.RemoteWebDriver driver)
-
getAppInfo
public static String getAppInfo(org.openqa.selenium.remote.RemoteWebDriver driver, String property)
-
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
public static String getCurrentContext(org.openqa.selenium.remote.RemoteWebDriver driver)
- Parameters:
driver-- Returns:
- the current context - "NATIVE_APP", "WEBVIEW", "VISUAL"
-
pressKey
public static void pressKey(org.openqa.selenium.remote.RemoteWebDriver driver, String keySequence)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
public static void touch(org.openqa.selenium.remote.RemoteWebDriver driver, String point)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
public static void setLocation(org.openqa.selenium.remote.RemoteWebDriver driver, String location, String by)
-
getDeviceLocation
public static String getDeviceLocation(org.openqa.selenium.remote.RemoteWebDriver driver)
-
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
public static void setTimezone(org.openqa.selenium.remote.RemoteWebDriver driver, String timezone)
-
getTimezone
public static String getTimezone(org.openqa.selenium.remote.RemoteWebDriver driver)
-
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
public static void executePerfectoCommand(org.openqa.selenium.remote.RemoteWebDriver driver, String command, Map<String,String> params)
-
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
-
-