Class MobileDeviceUtils


  • public class MobileDeviceUtils
    extends Object
    • Constructor Detail

      • MobileDeviceUtils

        public MobileDeviceUtils​(MobileDriver uiDriver)
    • Method Detail

      • listFiles

        public FileInfo[] listFiles​(String path)
        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
      • getMD5Sum

        public String getMD5Sum​(String filePath)
        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
      • deleteDirectory

        public void deleteDirectory​(String directoryPath,
                                    boolean recursively)
        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)
        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)
        Parameters:
        directoryPath - the directory for creation
      • copyFileTo

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

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

        public boolean isAdbOnWindows()
      • executeAdbCommand

        public IProcessExecutor executeAdbCommand​(String[] commandArguments,
                                                  boolean verifyExitCode)