Package com.workfusion.rpa.helpers
Class Resource
java.lang.Object
com.workfusion.rpa.helpers.Resource
This class adds static methods for work this file system.
Driver Type: Desktop
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAppends content to filestatic voidCopies file or directory.static voidcopyOverwrite(String resourceFrom, String pathTo) Copies file or directory.static voidCopies file or directory.static booleancreateDirectoryFail(String path) Creates new directory.static booleanCreates new directory.static booleancreateDirectorySkip(String path) Creates new directory.static booleancreateFileFail(String path) Create new file.static booleancreateFileOverwrite(String path) Create new file.static booleancreateFileSkip(String path) Create new file.static booleanDelete file or directorystatic booleanCheck if file or directory existslistFolder(String path) Lists directory contents of fileslistFolder(String path, Filter filter) Lists directory contents usingspcial filterstatic voidMoves file or directory.static voidmoveOverwrite(String resourceFrom, String pathTo) Moves file or directory.static voidMoves file or directory.static voidOverwrites file contentstatic StringReads file content
-
Method Details
-
exist
Check if file or directory existsDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory.- Returns:
- boolean representation of resource existence
- Example
def filePath = 'D://temp//whokilledkennedy.docx'boolean exist = Resource.exist(filePath);
-
delete
Delete file or directoryDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory.- Returns:
- boolean representation of operation success
- Example
def filePath = 'D://temp//whitneses.docx'boolean deleted = Resource.delete(filePath);
-
createFileOverwrite
Create new file. Overwrite, if file already existsDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory.- Returns:
- always returns true
- Example
def filePath = 'D://temp//whitneses.txt'boolean created = Resource.createFileOverwrite(filePath);
-
createFileSkip
Create new file. Skip, if file already existsDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory.- Returns:
- boolean representation of operation success. True - new file was created. False - file already existed
- Example
def filePath = 'D://temp//takeovertheworld.pptx'boolean created = Resource.createFileSkip(filePath);
-
createFileFail
Create new file. Fail with exception, if file already existsDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory.- Returns:
- boolean representation of operation success
- Throws:
org.openqa.selenium.WebDriverException- if file already exist- Example
def filePath = 'D://temp//takeovertheworld.pptx'boolean created = Resource.createFileFail(filePath);
-
listFolder
Lists directory contents of filesDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory- Returns:
- list representation of full path to files in specified directory
- Example
def filePath = 'D://temp'List folderContent = Resource.listFolder(filePath);
-
listFolder
Lists directory contents usingspcial filterDriver Type: Desktop
- Parameters:
path- string representation of path to file or directoryfilter- Filter- Returns:
- list of full path to filtered files or/and folders in specified directory(and subdirectories, if specified)
- Example
def filePath = 'D://temp'List folderContent = Resource.listFolder(filePath, Filter.files().pattern('tempFile.*tmp').get());
- See Also:
-
createDirectoryOverwrite
Creates new directory. Overwrite, if directory already existsDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory- Returns:
- always returns true
- Example
def filePath = 'D://temp//newDirectory'boolean created = Resource.createDirectoryOverwrite(filePath);
-
createDirectorySkip
Creates new directory. Skip, if directory already existsDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory- Returns:
- boolean representation of operation success. True - new directory was created. False - directory already existed
- Example
def filePath = 'D://temp//newDirectory'boolean created = Resource.createDirectorySkip(filePath);
-
createDirectoryFail
Creates new directory. Fails, if directory already existsDriver Type: Desktop
- Parameters:
path- string representation of path to file or directory- Returns:
- always returns true
- Throws:
org.openqa.selenium.WebDriverException- if directory exist- Example
def filePath = 'D://temp//newDirectory'boolean created = Resource.createDirectoryFail(filePath);
-
read
Reads file contentDriver Type: Desktop
- Parameters:
path- string representation of path to file or directoryencoding- string representation of file encoding- Returns:
- string representation of file content
- Example
def filePath = 'D://temp//newDirectory//file.txt'def content = Resource.read(filePath, 'utf-8');
-
overwrite
Overwrites file contentDriver Type: Desktop
- Parameters:
path- string representation of path to file or directoryvalue- string representation of text to overwrite withencoding- string representation of file encoding- Example
def filePath = 'D://temp//newDirectory//file.txt'Resource.overwrite(filePath, 'utf-8');
-
append
Appends content to fileDriver Type: Desktop
- Parameters:
path- string representation of path to file or directoryvalue- string representation of text to appendencoding- string representation of file encoding- Example
def filePath = 'D://temp//newDirectory//file.txt'Resource.append(filePath, 'added Text', 'utf-8');
-
copyOverwrite
Copies file or directory. Overwrites if file/directory already existDriver Type: Desktop
- Parameters:
resourceFrom- string representation of path to file or directory which should be copiedpathTo- string representation of a copy destination path- Example
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.copyOverwrite(filePath, 'added Text', 'utf-8');
-
copySkip
Copies file or directory. Skips if file/directory already existDriver Type: Desktop
- Parameters:
resourceFrom- string representation of path to file or directory which should be copiedpathTo- string representation of a copy destination path- Example
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.copySkip(resourceFrom, pathTo);
-
copyFail
Copies file or directory. Fails if file/directory already existDriver Type: Desktop
- Parameters:
resourceFrom- string representation of path to file or directory which should be copiedpathTo- string representation of a copy destination path- Throws:
org.openqa.selenium.WebDriverException-- Example
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.copyFail(resourceFrom, pathTo);
-
moveOverwrite
Moves file or directory. Overwrites if file/directory already existDriver Type: Desktop
- Parameters:
resourceFrom- string representation of path to file or directory which should be copiedpathTo- string representation of a copy destination path- Example
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.moveOverwrite(resourceFrom, pathTo);
-
moveSkip
Moves file or directory. Skips if file/directory already existDriver Type: Desktop
- Parameters:
resourceFrom- string representation of path to file or directory which should be copiedpathTo- string representation of a copy destination path- Example
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.moveSkip(resourceFrom, pathTo);
-
moveFail
Moves file or directory. Fails if file/directory already existDriver Type: Desktop
- Parameters:
resourceFrom- string representation of path to file or directory which should be copiedpathTo- string representation of a copy destination path- Throws:
org.openqa.selenium.WebDriverException-- Example
def resourceFrom = 'D://temp//file.txt'def pathTo = 'D://temp//newDirectory//file.txt'Resource.moveSkip(resourceFrom, pathTo);
-