Package io.github.the_sdet.common
Class CommonUtils
java.lang.Object
io.github.the_sdet.common.CommonUtils
This class handles various common Utilities and Helper methods
- Author:
- Pabitra Swain ([email protected])
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing the status of a test scenario. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDate(String inputDateStr, String inputDateFormat, String outputDateFormat) Format a date string from one format to another.getEmailBasedOnTimestamp(String prefix, String domain) Generates an email based on timestamp using format ddMMHHmmss E.g., if prefix is test and domain is gmail, it will generate - [email protected]static intgetIntegerValue(String elementText) This method extracts numeric integer value from a string.static doublegetNumericValue(String elementText) This method extracts numeric value from a string.Generates a ten-digit phone number based on timestamp using format ddMMHHmmssstatic StringreplaceLineBreaksWithSpace(String input) Replaces line breaks in the input string with spaces.static voidWaits for the specified duration.
-
Field Details
-
EMPTY_STRING
Represents a String without content. -
DOT_COM
Represents the String '.com' -
AT
Represents the String '@' -
generatedTenDigitNumber
Holds the generated ten-digit number by method getPhoneNumberBasedOnTimestamp()
-
-
Constructor Details
-
CommonUtils
public CommonUtils()
-
-
Method Details
-
getNumericValue
This method extracts numeric value from a string. E.g., -$300.00 will return 300.00- Parameters:
elementText- String value from which number to be extracted.- Returns:
- number in double format
-
getIntegerValue
This method extracts numeric integer value from a string. E.g., -$300.00 will return 300- Parameters:
elementText- String value from which number to be extracted.- Returns:
- number in integer format
-
waitFor
Waits for the specified duration.- Parameters:
duration- The duration to wait.
-
replaceLineBreaksWithSpace
Replaces line breaks in the input string with spaces.- Parameters:
input- The input string.- Returns:
- The input string with line breaks replaced by spaces.
-
formatDate
public static String formatDate(String inputDateStr, String inputDateFormat, String outputDateFormat) Format a date string from one format to another.- Parameters:
inputDateStr- The input date string.inputDateFormat- The input date format.outputDateFormat- The output date format.- Returns:
- the formatted date string.
-
getPhoneNumberBasedOnTimestamp
Generates a ten-digit phone number based on timestamp using format ddMMHHmmss- Returns:
- ten-digit number
-
getEmailBasedOnTimestamp
Generates an email based on timestamp using format ddMMHHmmss E.g., if prefix is test and domain is gmail, it will generate - [email protected]- Parameters:
prefix- prefix of emaildomain- domain of email- Returns:
- ten-digit number
-