public class FilesAndFolders extends Object
Modifier and Type | Field and Description |
---|---|
static org.openqa.selenium.WebDriver |
driver
The driver.
|
Constructor and Description |
---|
FilesAndFolders(org.openqa.selenium.WebDriver driver)
Instantiates a new files and folders.
|
Modifier and Type | Method and Description |
---|---|
static void |
copyFile(File sourceFile,
File destFile)
Copy file from source to destination.
|
static void |
downloadFileInIE(org.openqa.selenium.WebElement webElementOfDownloadLink)
Download file in IE via Java Robot Library.
|
static boolean |
fileExists(String fileNameWithPath)
File exists.
|
static File[] |
getAllFilesAndFolderNamesFromDir(String dirPath)
Gets the all files and folder names from the given directory.
|
static List |
getAllFilesAndFolderNamesFromDir(String dirPath,
String fileNameContains)
Gets the all files and folder containing a 'String' in the name, from the given directory.
|
static File |
getLastModifiedFileFromDir(String dirPath)
Gets the last modified file from given directory.
|
static String |
getProjectRootPath()
Gets the project root path.
|
static String |
getPropValue(String key)
Gets the property value for the key(passed as parameter) from the config.properties file located at project root
|
static String |
getPropValue(String key,
String filePath)
Gets the property value for the key(passed as parameter) from the .properties file path specified
|
static jxl.Cell[] |
readExcel(String sheetName,
String uniqueValue)
Reads a default excel file(located at: ./testdata/webTestData.xls) and returns the entire record for the uniqueValue specified from the sheetName specified.
|
static jxl.Cell[] |
readExcel(String filePath,
String sheetName,
String uniqueValue)
Reads an excel file(located at filePath passed as parameter) and returns the entire record for the uniqueValue specified from the sheetName specified.
|
static ArrayList |
readExcelColumnFromKeywordOnwards(String sheetName,
String keyWord)
Read excel(located at default location:"./testdata/webTestData.xls") column from keyword onwards until it finds the empty cell.
|
static ArrayList |
readExcelColumnFromKeywordOnwards(String fileNameWithPath,
String sheetName,
String keyWord)
Read excel(located at custom location - filePath passed as parameter) column from keyword onwards until it finds the empty cell.
|
static ArrayList |
readExcelColumnFromStart(String sheetName,
int coulumnNo)
Read excel(located at default location:"./testdata/webTestData.xls") column from start, until it finds the empty cell.
|
static ArrayList |
readExcelColumnFromStart(String fileNameWithPath,
String sheetName,
int coulumnNo)
Read excel(located at custom location - fileNameWithPath passed as parameter) column from start, until it finds the empty cell.
|
static jxl.Cell[] |
readExcelNextRowOfUniqueValue(String sheetName,
String uniqueValue)
Reads an excel file(located at: ./testdata/webTestData.xls) and returns 1 specific record which is just below the uniqueValue specified in the sheetName(specified as parameter).
|
static jxl.Cell[] |
readExcelNextRowOfUniqueValue(String filePath,
String sheetName,
String uniqueValue)
Reads an excel file(located at filePath passed as parameter) and returns 1 specific record which is just below the uniqueValue specified in the sheetName(specified as parameter).
|
static void |
setPropValue(String key,
String value)
Sets the property value for the Key(passed as parameter) in config.properties located at project root
|
static void |
uploadAttachmentForWindowsViaJavaRobotLib(String filePathInProject)
Upload attachment via java robot library for windows operating system.
|
public FilesAndFolders(org.openqa.selenium.WebDriver driver)
driver
- the driverpublic static String getPropValue(String key) throws Exception
key
- the key which exists in config.properties fileIOException
- Signals that an I/O exception has occurred.BadPaddingException
IllegalBlockSizeException
InvalidAlgorithmParameterException
NoSuchPaddingException
NoSuchAlgorithmException
InvalidKeyException
NumberFormatException
Exception
public static String getPropValue(String key, String filePath) throws Exception
key
- the key which exists in .properties file specifiedfilePath
- the file path for the .properties file. Ex: "./config.properties"Exception
- the exceptionNumberFormatException
- the number format exceptionpublic static void setPropValue(String key, String value) throws IOException, Exception
key
- the key which exists in config.properties filevalue
- the value which you wish to assign to the key in config.properties fileIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static jxl.Cell[] readExcel(String sheetName, String uniqueValue) throws jxl.read.biff.BiffException, IOException, Exception
sheetName
- the sheet name from which you wish to read and return a recorduniqueValue
- the unique value for which the entire record(row) will be returnedjxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static jxl.Cell[] readExcel(String filePath, String sheetName, String uniqueValue) throws jxl.read.biff.BiffException, IOException, Exception
filePath
- the file path Ex:"./testdata/webTestData.xls"sheetName
- the sheet name from which you wish to read and return a recorduniqueValue
- the unique value for which the entire record(row) will be returnedjxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static jxl.Cell[] readExcelNextRowOfUniqueValue(String sheetName, String uniqueValue) throws jxl.read.biff.BiffException, IOException, Exception
sheetName
- the sheet name from which you wish to read and return a recorduniqueValue
- the unique value for which the entire record(row) will be returnedjxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static jxl.Cell[] readExcelNextRowOfUniqueValue(String filePath, String sheetName, String uniqueValue) throws jxl.read.biff.BiffException, IOException, Exception
filePath
- the file path Ex:"./testdata/webTestData.xls"sheetName
- the sheet name from which you wish to read and return a recorduniqueValue
- the unique value for which the entire record(row) will be returnedjxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static ArrayList readExcelColumnFromKeywordOnwards(String sheetName, String keyWord) throws jxl.read.biff.BiffException, IOException, Exception
sheetName
- the sheet namekeyWord
- the key word(next cell) from which you wish to get the datajxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static ArrayList readExcelColumnFromKeywordOnwards(String fileNameWithPath, String sheetName, String keyWord) throws jxl.read.biff.BiffException, IOException, Exception
fileNameWithPath
- the file name with path. Ex:"./testdata/linkCheckerInputData.xls"sheetName
- the sheet namekeyWord
- the key word(next cell) from which you wish to get the datajxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static ArrayList readExcelColumnFromStart(String sheetName, int coulumnNo) throws jxl.read.biff.BiffException, IOException, Exception
sheetName
- the sheet name from which column data is to be extractedcoulumnNo
- the coulumn no. Index starts from 0 for Column A.jxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static ArrayList readExcelColumnFromStart(String fileNameWithPath, String sheetName, int coulumnNo) throws jxl.read.biff.BiffException, IOException, Exception
fileNameWithPath
- the file name with path. Ex:"./testdata/linkCheckerInputData.xls"sheetName
- the sheet name from which column data is to be extractedcoulumnNo
- the coulumn no. Index starts from 0 for Column A.jxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
- the exceptionpublic static void copyFile(File sourceFile, File destFile) throws Exception
sourceFile
- the source file with path. Ex:"D:\\workspace\\BTAC_SeleniumAppiumLibrary\\testdata\\sample.docx"destFile
- the destination file with path. Ex:"D:\\workspace\\BTAC_SeleniumAppiumLibrary\\testdata\\sampleCopy.docx"Exception
- the exceptionpublic static String getProjectRootPath() throws Exception
Exception
public static void uploadAttachmentForWindowsViaJavaRobotLib(String filePathInProject) throws Exception
filePathInProject
- the file path in project. Ex: "\\testdata\\webTestData.xls"Exception
public static void downloadFileInIE(org.openqa.selenium.WebElement webElementOfDownloadLink) throws Exception
webElementOfDownloadLink
- the web element of download linkException
- the exceptionpublic static File getLastModifiedFileFromDir(String dirPath) throws Exception
dirPath
- the directory path. Ex:"D:\\Softwares\\workspacePersonal\\BTAC_SeleniumAppiumLibrary"Exception
public static File[] getAllFilesAndFolderNamesFromDir(String dirPath) throws Exception
dirPath
- the directory path. Ex:"D:\\Softwares\\workspacePersonal\\BTAC_SeleniumAppiumLibrary"Exception
- the exceptionpublic static List getAllFilesAndFolderNamesFromDir(String dirPath, String fileNameContains) throws Exception
dirPath
- the directory path. Ex:"D:\\Softwares\\workspacePersonal\\BTAC_SeleniumAppiumLibrary"fileNameContains
- the string value which should be contained in all file namesException
- the exception