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) |
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
|
protected static ZipOutputStream |
createZip(String destZipFile) |
protected static void |
executeJavascript(String script) |
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 |
getCurrentDir()
get current directory
|
protected static ArrayList<File> |
getFileList(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 |
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 |
isMac()
returns true if OS is mac
|
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 |
killWindowsProcess(String serviceName)
returns kills the process if running
|
protected static ArrayList<String> |
runShellCommand(String cmd)
runs shell command And returns results as an array list
|
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
|
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 ArrayList<String> runShellCommand(String cmd)
cmd - 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 getCurrentDir()
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> getFileList(String directoryPath, String type)
protected static List<File> getFileListWithSubfolders(String directoryName, String type, List<File> files)
protected static void createFileFromPath(String absolutePath)
path - 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 - Copyright © 2019. All rights reserved.