Class CommonUtils

java.lang.Object
io.github.the_sdet.common.CommonUtils

public class CommonUtils extends Object
This class handles various common Utilities and Helper methods
Author:
Pabitra Swain ([email protected])
  • Field Details

    • EMPTY_STRING

      public static String EMPTY_STRING
      Represents a String without content.
    • DOT_COM

      public static String DOT_COM
      Represents the String '.com'
    • AT

      public static String AT
      Represents the String '@'
    • generatedTenDigitNumber

      public static String generatedTenDigitNumber
      Holds the generated ten-digit number by method getPhoneNumberBasedOnTimestamp()
  • Constructor Details

    • CommonUtils

      public CommonUtils()
  • Method Details

    • getNumericValue

      public static double getNumericValue(String elementText)
      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

      public static int getIntegerValue(String elementText)
      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

      public static void waitFor(Duration duration)
      Waits for the specified duration.
      Parameters:
      duration - The duration to wait.
    • replaceLineBreaksWithSpace

      public static String replaceLineBreaksWithSpace(String input)
      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

      public String getPhoneNumberBasedOnTimestamp()
      Generates a ten-digit phone number based on timestamp using format ddMMHHmmss
      Returns:
      ten-digit number
    • getEmailBasedOnTimestamp

      public String 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]
      Parameters:
      prefix - prefix of email
      domain - domain of email
      Returns:
      ten-digit number