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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    cleanApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)
     
    static void
    closeApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)
     
    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)
     
    static Map<String,Object>
    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
    pressKey(org.openqa.selenium.remote.RemoteWebDriver driver, String keySequence)
    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
    startApp(org.openqa.selenium.remote.RemoteWebDriver driver, String app, String by)
     
    static void
    swipe(org.openqa.selenium.remote.RemoteWebDriver driver, String start, String end)
    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
    touch(org.openqa.selenium.remote.RemoteWebDriver driver, String point)
    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
    uploadMedia(String host, String user, String password, String path, String repositoryKey)
    Uploads a file to the media repository.
    static void
    uploadMedia(String host, String user, String password, URL mediaURL, String repositoryKey)
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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");
      Throws:
      UnsupportedEncodingException
      MalformedURLException
      IOException
    • 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 RemoteWebDriver
      keySequence - 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 RemoteWebDriver
      start - 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 RemoteWebDriver
      point - 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 RemoteWebDriver
      restValue - 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
    • getDeviceProperties

      public static Map<String,Object> getDeviceProperties(org.openqa.selenium.Capabilities capabilities)