Class SpectrumEntity<T extends SpectrumEntity<T,Data>,Data>

java.lang.Object
io.github.giulong.spectrum.SpectrumEntity<T,Data>
Direct Known Subclasses:
SpectrumPage, SpectrumTest

public abstract class SpectrumEntity<T extends SpectrumEntity<T,Data>,Data> extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.openqa.selenium.interactions.Actions
     
    protected Configuration
     
    protected Data
     
    protected org.openqa.selenium.support.ui.WebDriverWait
     
    protected org.openqa.selenium.WebDriver
     
     
    protected com.aventstack.extentreports.ExtentReports
     
    protected com.aventstack.extentreports.ExtentTest
     
    static final String
     
    protected org.openqa.selenium.support.ui.WebDriverWait
     
    protected Js
     
    protected org.openqa.selenium.support.ui.WebDriverWait
     
    protected org.openqa.selenium.support.ui.WebDriverWait
     
    protected TestData
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.aventstack.extentreports.model.Media
    addScreenshotToReport(String msg, com.aventstack.extentreports.Status status)
    Adds a screenshot with the provided message and the provided status to the current test in the Extent Report
    boolean
    Leverages the waitForDownloadOf method and then compares the checksums of the file provided.
    boolean
    checkDownloadedFile(String downloadedFileName, String fileToCheckName)
    Leverages the waitForDownloadOf method and then compares the checksums of the two files provided.
    org.openqa.selenium.WebElement
    clearAndSendKeys(org.openqa.selenium.WebElement webElement, CharSequence keysToSend)
    Helper method to call Selenium's clear and sendKeys on the provided WebElement, which is then returned
    void
    Deletes the download folder (its path is provided in the configuration*.yaml)
    protected List<Field>
     
    boolean
    hasClass(org.openqa.selenium.WebElement webElement, String className)
    Checks if the provided WebElement has the provided css class
    boolean
    hasClasses(org.openqa.selenium.WebElement webElement, String... classes)
    Checks if the provided WebElement has all the provided css classes
    hover(org.openqa.selenium.WebElement webElement)
    Hovers on the provided WebElement, leveraging the actions field
    boolean
    isNotPresent(org.openqa.selenium.By by)
    Checks if no WebElement with the provided by is present in the current page
    boolean
    isPresent(org.openqa.selenium.By by)
    Checks if the WebElement with the provided by is present in the current page
    Adds a screenshot at INFO level to the current test in the Extent Report
    Adds a screenshot with the provided message and FAIL status to the current test in the Extent Report
    Adds a screenshot with the provided message and INFO status to the current test in the Extent Report
    Adds a screenshot status with the provided message and WARN to the current test in the Extent Report
    protected static byte[]
    sha256Of(Path file)
     
    upload(org.openqa.selenium.WebElement webElement, String fileName)
    Uploads to the provided WebElement (usually an input field with type="file") the file with the provided name, taken from the configurable runtime.filesFolder.
    Leverages the configurable downloadWait to check fluently if the file at the provided path is fully downloaded

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HASH_ALGORITHM

      public static final String HASH_ALGORITHM
      See Also:
    • configuration

      protected Configuration configuration
    • extentReports

      protected com.aventstack.extentreports.ExtentReports extentReports
    • extentTest

      protected com.aventstack.extentreports.ExtentTest extentTest
    • actions

      protected org.openqa.selenium.interactions.Actions actions
    • testData

      protected TestData testData
    • driver

      protected org.openqa.selenium.WebDriver driver
    • implicitWait

      protected org.openqa.selenium.support.ui.WebDriverWait implicitWait
    • pageLoadWait

      protected org.openqa.selenium.support.ui.WebDriverWait pageLoadWait
    • scriptWait

      protected org.openqa.selenium.support.ui.WebDriverWait scriptWait
    • downloadWait

      protected org.openqa.selenium.support.ui.WebDriverWait downloadWait
    • eventsDispatcher

      protected EventsDispatcher eventsDispatcher
    • js

      protected Js js
    • data

      protected Data data
  • Constructor Details

    • SpectrumEntity

      public SpectrumEntity()
  • Method Details

    • getSharedFields

      protected List<Field> getSharedFields()
    • hover

      public T hover(org.openqa.selenium.WebElement webElement)
      Hovers on the provided WebElement, leveraging the actions field
      Parameters:
      webElement - the WebElement on which to hover
      Returns:
      the calling SpectrumEntity instance
    • screenshot

      public T screenshot()
      Adds a screenshot at INFO level to the current test in the Extent Report
      Returns:
      the calling SpectrumEntity instance
    • screenshotInfo

      public T screenshotInfo(String msg)
      Adds a screenshot with the provided message and INFO status to the current test in the Extent Report
      Parameters:
      msg - the message to log
      Returns:
      the calling SpectrumEntity instance
    • screenshotWarning

      public T screenshotWarning(String msg)
      Adds a screenshot status with the provided message and WARN to the current test in the Extent Report
      Parameters:
      msg - the message to log
      Returns:
      the calling SpectrumEntity instance
    • screenshotFail

      public T screenshotFail(String msg)
      Adds a screenshot with the provided message and FAIL status to the current test in the Extent Report
      Parameters:
      msg - the message to log
      Returns:
      the calling SpectrumEntity instance
    • addScreenshotToReport

      public com.aventstack.extentreports.model.Media addScreenshotToReport(String msg, com.aventstack.extentreports.Status status)
      Adds a screenshot with the provided message and the provided status to the current test in the Extent Report
      Parameters:
      msg - the message to log
      status - the log's status
      Returns:
      the generated screenshot
    • deleteDownloadsFolder

      public void deleteDownloadsFolder()
      Deletes the download folder (its path is provided in the configuration*.yaml)
    • waitForDownloadOf

      public T waitForDownloadOf(Path path)
      Leverages the configurable downloadWait to check fluently if the file at the provided path is fully downloaded
      Parameters:
      path - the path to the downloaded file to wait for
      Returns:
      the calling SpectrumEntity instance
    • checkDownloadedFile

      public boolean checkDownloadedFile(String downloadedFileName, String fileToCheckName)
      Leverages the waitForDownloadOf method and then compares the checksums of the two files provided.
      Parameters:
      downloadedFileName - name of the downloaded file
      fileToCheckName - name of the static file to be used as comparison
      Returns:
      true if the files are equal
    • checkDownloadedFile

      public boolean checkDownloadedFile(String file)
      Leverages the waitForDownloadOf method and then compares the checksums of the file provided.
      Parameters:
      file - name of both the downloaded file and the static one to be used as comparison
      Returns:
      true if the files are equal
    • clearAndSendKeys

      public org.openqa.selenium.WebElement clearAndSendKeys(org.openqa.selenium.WebElement webElement, CharSequence keysToSend)
      Helper method to call Selenium's clear and sendKeys on the provided WebElement, which is then returned
      Parameters:
      webElement - target WebElement
      keysToSend - keys to send
      Returns:
      the target WebElement passed as argument
    • upload

      public T upload(org.openqa.selenium.WebElement webElement, String fileName)
      Uploads to the provided WebElement (usually an input field with type="file") the file with the provided name, taken from the configurable runtime.filesFolder.
      Parameters:
      webElement - target WebElement
      fileName - name of the file to be uploaded
      Returns:
      the calling SpectrumEntity instance
    • isPresent

      public boolean isPresent(org.openqa.selenium.By by)
      Checks if the WebElement with the provided by is present in the current page
      Parameters:
      by - the WebElement's selector
      Returns:
      true if the WebElement is found
    • isNotPresent

      public boolean isNotPresent(org.openqa.selenium.By by)
      Checks if no WebElement with the provided by is present in the current page
      Parameters:
      by - the WebElement's selector
      Returns:
      true if the WebElement is not found
    • hasClass

      public boolean hasClass(org.openqa.selenium.WebElement webElement, String className)
      Checks if the provided WebElement has the provided css class
      Parameters:
      webElement - the WebElement to check
      className - the css class to look for
      Returns:
      true if the WebElement has the provided css class
    • hasClasses

      public boolean hasClasses(org.openqa.selenium.WebElement webElement, String... classes)
      Checks if the provided WebElement has all the provided css classes
      Parameters:
      webElement - the WebElement to check
      classes - the css classes to look for
      Returns:
      true if the WebElement has all the provided css classes
    • sha256Of

      protected static byte[] sha256Of(Path file)