public class UtilityHelper extends Object
| Constructor and Description |
|---|
UtilityHelper() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addFileToZip(String path,
String srcFile,
ZipOutputStream zip) |
protected static void |
appendToFile(String value,
String absolutePath)
appends to existing file
|
protected static void |
appendToFile(String value,
String directory,
String filename,
String type)
appends to existing file
|
static File |
captureElementPicture(EnhancedBy element)
Gets a picture of specific element displayed on the page
|
static File |
captureElementPicture(EnhancedBy element,
int index)
Gets a picture of specific element displayed on the page
|
protected static void |
captureExtentReportScreenshot()
captures screenshot And attaches to extent test report
|
protected static void |
copyDirectory(String dirFrom,
String dirTo)
Copies directory And all content from dirFrom to dirTo overwrites the content
|
protected static void |
createFileFromPath(String absolutePath)
create directories and files based on absolute path
set permissions to rw-r--r--
set executable to true
|
protected static ZipOutputStream |
createZip(String destZipFile) |
protected static void |
deleteFile(String absolutePath)
delete file
|
protected static ArrayList<String> |
excuteCommand(String command)
run command and return results as array list
will run bash on linux or mac
will run batch command on windows
|
protected static ArrayList<String> |
excuteCommandFromFile(String filePath)
run script file and return results as array list
will run bash on linux or mac
will run batch command on windows
|
protected static void |
executeJavascript(String script) |
protected static Object |
executeJs(String script,
Object... args)
execute javascript
|
protected static List<String> |
executeJsWithListReturn(String script,
Object... args)
execute javascript
|
protected static String |
executeJsWithStringReturn(String script,
Object... args)
execute javascript
|
protected static String |
generateRandomInteger(int len)
generates random int of length len
|
protected static int |
generateRandomNumber(int min,
int max)
generates random number between two numbers, min, max
|
protected static String |
generateRandomString(int len)
generates random string of length len
|
protected static List<String> |
getAllValuesStartringWith(String source,
String value)
gets a list of string from 'source' starting with 'value'
|
protected static String |
getFileContent(String absolutePath)
gets file content as String
|
protected static ArrayList<File> |
getFileList(String directoryPath)
returns the list of files in directory
|
protected static ArrayList<File> |
getFileListByType(String directoryPath,
String type)
gets the list of files tye: file type.
|
protected static List<File> |
getFileListWithSubfolders(String directoryName,
String type,
List<File> files)
gets list of files including from sub folder based on type.
|
protected static String |
getRootDir()
get current project root directory, where pom.xml is
|
protected static String |
getValueFromPattern(String str,
String pattern) |
protected static List<String> |
getValuesFromPattern(String str,
String pattern) |
protected static void |
highLightWebElement(EnhancedBy by,
int index)
highlights the web element
use on clicks and send key elements
applicable to web driver
|
protected static boolean |
isBoolean(String value)
returns if string is boolean
|
protected static boolean |
isMac()
returns true if OS is mac
|
protected static boolean |
isNumeric(String str)
return if string is a number
|
protected static boolean |
isProcessRunning(String serviceName)
returns true if process is running
|
protected static boolean |
isUnix()
returns true if OS is unix or linux
|
protected static boolean |
isUUID(String value)
is the string value UDID
|
protected static boolean |
isWindows()
returns true if OS is windows
|
protected static void |
killMacProcess(String serviceName) |
protected static void |
killWindowsProcess(String serviceName)
returns kills the process if running
|
static void |
slackNotificationWithFile(String title,
String comment,
String filePath)
sends slack notification token: generate at:
https://api.slack.com/custom-integrations/legacy-tokens for channel id: right
click And channel And copy link.
|
protected static String |
stringNormalize(String value)
normalizes string removes space, new line chars, quotes
|
protected static String |
stringRemoveLines(String value)
normalizes string removes space, new line chars
|
protected static void |
writeFile(String value,
String absolutePath)
Create file (where pom.xml is) and write to it
|
protected static void |
writeFile(String value,
String directory,
String filename,
String type)
Create file with path starting from root directory (where pom.xml is) and
write to it.
|
static String |
zipDir(String sourceDir,
String destFilePath)
zips directory path starts from root pom directory
|
protected static ZipOutputStream |
zipFolder(String srcFolder,
String destZipFile)
zip folder
|
protected static String generateRandomString(int len)
len - protected static String generateRandomInteger(int len)
len - protected static int generateRandomNumber(int min,
int max)
min - max - protected static String stringNormalize(String value)
value - protected static String stringRemoveLines(String value)
value - protected static boolean isProcessRunning(String serviceName) throws Exception
serviceName - Exceptionprotected static void killWindowsProcess(String serviceName)
serviceName - Exceptionprotected static void killMacProcess(String serviceName)
protected static ArrayList<String> excuteCommand(String command)
command - IOExceptionprotected static ArrayList<String> excuteCommandFromFile(String filePath)
filePath - path from the root directory ( where pom.xml is )protected static void copyDirectory(String dirFrom, String dirTo)
dirFrom - dirTo - protected static void executeJavascript(String script)
protected static ZipOutputStream zipFolder(String srcFolder, String destZipFile) throws Exception
srcFolder - destZipFile - Exceptionprotected static ZipOutputStream createZip(String destZipFile) throws FileNotFoundException
FileNotFoundExceptionprotected static void addFileToZip(String path, String srcFile, ZipOutputStream zip) throws Exception
Exceptionprotected static List<String> getAllValuesStartringWith(String source, String value)
source - value - protected static String getValueFromPattern(String str, String pattern)
str - pattern - regular expression patternprotected static List<String> getValuesFromPattern(String str, String pattern)
str - pattern - regular expression patternprotected static String getRootDir()
public static void slackNotificationWithFile(String title, String comment, String filePath)
public static String zipDir(String sourceDir, String destFilePath)
sourceDir: - root path + dirdestFilePath: - usage: root + dir + outputFilePathprotected static ArrayList<File> getFileListByType(String directoryPath, String type)
protected static ArrayList<File> getFileList(String directoryPath)
directoryPath - protected static List<File> getFileListWithSubfolders(String directoryName, String type, List<File> files)
protected static String getFileContent(String absolutePath)
absolutePath - protected static void createFileFromPath(String absolutePath)
path - protected static void writeFile(String value, String directory, String filename, String type)
value - value in filedirectory - directory from rootfilename - name of the filetype - type of fileprotected static void writeFile(String value, String absolutePath)
value - absolutePath - protected static void deleteFile(String absolutePath)
absolutePath - protected static void appendToFile(String value, String absolutePath)
value - absolutePath - protected static void appendToFile(String value, String directory, String filename, String type)
value - directory - filename - type - protected static void captureExtentReportScreenshot()
public static File captureElementPicture(EnhancedBy element)
element - The elementExceptionpublic static File captureElementPicture(EnhancedBy element, int index)
element - The elementExceptionprotected static void highLightWebElement(EnhancedBy by, int index)
by - index - protected static boolean isMac()
protected static boolean isWindows()
protected static boolean isUnix()
protected static boolean isUUID(String value)
value - protected static boolean isBoolean(String value)
value - protected static boolean isNumeric(String str)
str - protected static Object executeJs(String script, Object... args)
script - protected static List<String> executeJsWithListReturn(String script, Object... args)
script - Copyright © 2019. All rights reserved.