public class Resource extends Object
Driver Type: Desktop
| Modifier and Type | Method and Description |
|---|---|
static void |
append(String path,
String value,
String encoding)
Appends content to file
|
static void |
copyFail(String resourceFrom,
String pathTo)
Copies file or directory.
|
static void |
copyOverwrite(String resourceFrom,
String pathTo)
Copies file or directory.
|
static void |
copySkip(String resourceFrom,
String pathTo)
Copies file or directory.
|
static boolean |
createDirectoryFail(String path)
Creates new directory.
|
static boolean |
createDirectoryOverwrite(String path)
Creates new directory.
|
static boolean |
createDirectorySkip(String path)
Creates new directory.
|
static boolean |
createFileFail(String path)
Create new file.
|
static boolean |
createFileOverwrite(String path)
Create new file.
|
static boolean |
createFileSkip(String path)
Create new file.
|
static boolean |
delete(String path)
Delete file or directory
|
static boolean |
exist(String path)
Check if file or directory exists
|
static List<String> |
listFolder(String path)
Lists directory contents of files
|
static List<String> |
listFolder(String path,
Filter filter)
Lists directory contents using
spcial filter |
static void |
moveFail(String resourceFrom,
String pathTo)
Moves file or directory.
|
static void |
moveOverwrite(String resourceFrom,
String pathTo)
Moves file or directory.
|
static void |
moveSkip(String resourceFrom,
String pathTo)
Moves file or directory.
|
static void |
overwrite(String path,
String value,
String encoding)
Overwrites file content
|
static String |
read(String path,
String encoding)
Reads file content
|
public static boolean exist(String path)
Driver Type: Desktop
path - string representation of path to file or directory.def filePath = 'D://temp//whokilledkennedy.docx'boolean exist = Resource.exist(filePath);public static boolean delete(String path)
Driver Type: Desktop
path - string representation of path to file or directory.def filePath = 'D://temp//whitneses.docx'boolean deleted = Resource.delete(filePath);public static boolean createFileOverwrite(String path)
Driver Type: Desktop
path - string representation of path to file or directory.def filePath = 'D://temp//whitneses.txt'boolean created = Resource.createFileOverwrite(filePath);public static boolean createFileSkip(String path)
Driver Type: Desktop
path - string representation of path to file or directory.def filePath = 'D://temp//takeovertheworld.pptx'boolean created = Resource.createFileSkip(filePath);public static boolean createFileFail(String path)
Driver Type: Desktop
path - string representation of path to file or directory.org.openqa.selenium.WebDriverException - if file already exist
def filePath = 'D://temp//takeovertheworld.pptx'boolean created = Resource.createFileFail(filePath);public static List<String> listFolder(String path)
Driver Type: Desktop
path - string representation of path to file or directorydef filePath = 'D://temp'List folderContent = Resource.listFolder(filePath);public static List<String> listFolder(String path, Filter filter)
spcial filter
Driver Type: Desktop
path - string representation of path to file or directoryfilter - Filterdef filePath = 'D://temp'List folderContent = Resource.listFolder(filePath, Filter.files().pattern('tempFile.*tmp').get());Filterpublic static boolean createDirectoryOverwrite(String path)
Driver Type: Desktop
path - string representation of path to file or directorydef filePath = 'D://temp//newDirectory'boolean created = Resource.createDirectoryOverwrite(filePath);public static boolean createDirectorySkip(String path)
Driver Type: Desktop
path - string representation of path to file or directorydef filePath = 'D://temp//newDirectory'boolean created = Resource.createDirectorySkip(filePath);public static boolean createDirectoryFail(String path)
Driver Type: Desktop
path - string representation of path to file or directoryorg.openqa.selenium.WebDriverException - if directory exist
def filePath = 'D://temp//newDirectory'boolean created = Resource.createDirectoryFail(filePath);public static String read(String path, String encoding)
Driver Type: Desktop
path - string representation of path to file or directoryencoding - string representation of file encodingdef filePath = 'D://temp//newDirectory//file.txt'def content = Resource.read(filePath, 'utf-8');public static void overwrite(String path, String value, String encoding)
Driver Type: Desktop
path - string representation of path to file or directoryvalue - string representation of text to overwrite withencoding - string representation of file encoding
def filePath = 'D://temp//newDirectory//file.txt'Resource.overwrite(filePath, 'utf-8');public static void append(String path, String value, String encoding)
Driver Type: Desktop
path - string representation of path to file or directoryvalue - string representation of text to appendencoding - string representation of file encoding
def filePath = 'D://temp//newDirectory//file.txt'Resource.append(filePath, 'added Text', 'utf-8');public static void copyOverwrite(String resourceFrom, String pathTo)
Driver Type: Desktop
resourceFrom - string representation of path to file or directory which should be copiedpathTo - string representation of a copy destination path
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.copyOverwrite(filePath, 'added Text', 'utf-8');public static void copySkip(String resourceFrom, String pathTo)
Driver Type: Desktop
resourceFrom - string representation of path to file or directory which should be copiedpathTo - string representation of a copy destination path
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.copySkip(resourceFrom, pathTo);public static void copyFail(String resourceFrom, String pathTo)
Driver Type: Desktop
resourceFrom - string representation of path to file or directory which should be copiedpathTo - string representation of a copy destination pathorg.openqa.selenium.WebDriverException - def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.copyFail(resourceFrom, pathTo);public static void moveOverwrite(String resourceFrom, String pathTo)
Driver Type: Desktop
resourceFrom - string representation of path to file or directory which should be copiedpathTo - string representation of a copy destination path
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.moveOverwrite(resourceFrom, pathTo);public static void moveSkip(String resourceFrom, String pathTo)
Driver Type: Desktop
resourceFrom - string representation of path to file or directory which should be copiedpathTo - string representation of a copy destination path
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.moveSkip(resourceFrom, pathTo);public static void moveFail(String resourceFrom, String pathTo)
Driver Type: Desktop
resourceFrom - string representation of path to file or directory which should be copiedpathTo - string representation of a copy destination pathorg.openqa.selenium.WebDriverException - def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.moveSkip(resourceFrom, pathTo);Copyright 2016, WorkFusion, Inc.