Class MobileEngine.Device

    • Constructor Detail

      • Device

        public Device()
    • Method Detail

      • installApp

        public void installApp​(String appPath)

        Install application.

        NOTE: 'adb' executable must be in the $PATH variable in the environment of the Appium server
        Example: export PATH=/opt/android/android-sdk_r24.0.2/platform-tools/:$PATH

        Parameters:
        appPath - application absolute path or relative to the started Appium server
      • isAppInstalled

        public boolean isAppInstalled​(String appName)
        Parameters:
        appName - /. for Android (e.g. com.axway.st.mobile/.SecureTransportMobile) or bundle ID for iOS
        Returns:
        if the application is installed or if it is not
      • removeApp

        public void removeApp​(String appName)
        Parameters:
        appName - /. for Android (e.g. com.axway.st.mobile/.SecureTransportMobile) or bundle ID for iOS
      • resetApp

        public void resetApp()
      • pressHWButtonBack

        public void pressHWButtonBack()
      • pressHWButtonHome

        public void pressHWButtonHome()
      • runAppInBackground

        public void runAppInBackground​(int seconds)
        Runs the current app as a background app for the number of seconds requested. This is a synchronous method, it returns after the back has been returned to the foreground.
        Parameters:
        seconds - number of seconds to run App in background
      • runAppInBackground

        public void runAppInBackground​(int seconds,
                                       String appName)
        Runs the current app as a background app for the number of seconds requested. This is a synchronous method, it returns after the back has been returned to the foreground.
        Parameters:
        seconds - number of seconds to run App in background
        appName - /. for Android (e.g. com.axway.st.mobile/.SecureTransportMobile) or bundle ID for iOS
      • getMD5Sum

        public String getMD5Sum​(String filePath)
        Calculate file MD5 sum directly on the mobile device
        Parameters:
        filePath - file absolute path
        Note for iOS: You can specify relative path too, by skipping the root slash '/' at the beginning and pass the path relative to the application data folder
        For example: "Documents/MyAppFiles/IMG_0001.PNG"
        and we'll internally search for: "/Users/<username>/Library/Developer/CoreSimulator/Devices/<device_id>/data/Containers/Data/Application/<app_id>/Documents/MyAppFiles/IMG_0001.PNG"
        which is the iOS Simulator application data folder path
        Returns:
        the MD5 sum of the specified file
      • listFiles

        public FileInfo[] listFiles​(String path)
        List files and directories on the mobile device
        Parameters:
        path - a path on the mobile device. It can be a directory or file (if you want to check for specific file existence)
        Note for iOS: You have to specify a relative path to the application data folder
        For example: "Documents/MyAppFiles"
        and we'll internally search for files in: "/Users/<username>/Library/Developer/CoreSimulator/Devices/<device_id>/data/Containers/Data/Application/<app_id>/Documents/MyAppFiles/"
        which is the iOS Simulator application data folder path
        Returns:
        FileInfo array with all the files and folders from the target path
      • deleteDirectory

        public void deleteDirectory​(String directoryPath,
                                    boolean recursively)
        Deletes a directory from the mobile device
        Parameters:
        directoryPath - the directory for deletion
        recursively - whether to delete the internal directories recursively Note for iOS: You can specify relative directory path too, by skipping the root slash '/' at the beginning and pass the path relative to the application data folder
        For example: "Documents/MyAppFiles"
        and we'll internally search for: "/Users/<username>/Library/Developer/CoreSimulator/Devices/<device_id>/data/Containers/Data/Application/<app_id>/Documents/MyAppFiles/"
        which is the iOS Simulator application data folder path
      • deleteFile

        public void deleteFile​(String filePath)
        Deletes a file from the mobile device
        Parameters:
        filePath - the file for deletion Note for iOS: You can specify relative file path too, by skipping the root slash '/' at the beginning and pass the path relative to the application data folder
        For example: "Documents/MyAppFiles/fileToDelete"
        and we'll internally search for: "/Users/<username>/Library/Developer/CoreSimulator/Devices/<device_id>/data/Containers/Data/Application/<app_id>/Documents/MyAppFiles/fileToDelete"
        which is the iOS Simulator application data folder path
      • createDirectory

        public void createDirectory​(String directoryPath)
        Creates directory on mobile device
        Parameters:
        directoryPath - the directory for creation
      • copyFileTo

        public void copyFileTo​(String localFilePath,
                               String deviceFilePath)
        Copies file to device
        Parameters:
        localFilePath - local file path
        deviceFilePath - file path on the device
      • copyFileFrom

        public void copyFileFrom​(String deviceFilePath,
                                 String localFilePath)
        Copies file from device to local machine
        Parameters:
        deviceFilePath - file path on the device
        localFilePath - local file path
      • getClipboardText

        public String getClipboardText()
        Get clipboard contents with text assumed
        Returns:
        text contents