Package io.github.giulong.spectrum
Class SpectrumEntity<T extends SpectrumEntity<T,Data>,Data>
java.lang.Object
io.github.giulong.spectrum.SpectrumEntity<T,Data>
- Direct Known Subclasses:
SpectrumPage
,SpectrumTest
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.openqa.selenium.interactions.Actions
protected Configuration
protected Data
protected org.openqa.selenium.support.ui.WebDriverWait
protected org.openqa.selenium.WebDriver
protected EventsDispatcher
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
-
Method Summary
Modifier and TypeMethodDescriptioncom.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 Reportboolean
checkDownloadedFile
(String file) Leverages thewaitForDownloadOf
method and then compares the checksums of the file provided.boolean
checkDownloadedFile
(String downloadedFileName, String fileToCheckName) Leverages thewaitForDownloadOf
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'sclear
andsendKeys
on the provided WebElement, which is then returnedvoid
Deletes the download folder (its path is provided in theconfiguration*.yaml
)boolean
Checks if the provided WebElement has the provided css classboolean
hasClasses
(org.openqa.selenium.WebElement webElement, String... classes) Checks if the provided WebElement has all the provided css classeshover
(org.openqa.selenium.WebElement webElement) Hovers on the provided WebElement, leveraging theactions
fieldboolean
isNotPresent
(org.openqa.selenium.By by) Checks if no WebElement with the providedby
is present in the current pageboolean
isPresent
(org.openqa.selenium.By by) Checks if the WebElement with the providedby
is present in the current pageAdds a screenshot at INFO level to the current test in the Extent ReportscreenshotFail
(String msg) Adds a screenshot with the provided message and FAIL status to the current test in the Extent ReportscreenshotInfo
(String msg) Adds a screenshot with the provided message and INFO status to the current test in the Extent ReportscreenshotWarning
(String msg) Adds a screenshot status with the provided message and WARN to the current test in the Extent Reportprotected static byte[]
Uploads to the provided WebElement (usually an input field withtype="file"
) the file with the provided name, taken from the configurableruntime.filesFolder
.waitForDownloadOf
(Path path) Leverages the configurabledownloadWait
to check fluently if the file at the provided path is fully downloaded
-
Field Details
-
HASH_ALGORITHM
- See Also:
-
configuration
-
extentReports
protected com.aventstack.extentreports.ExtentReports extentReports -
extentTest
protected com.aventstack.extentreports.ExtentTest extentTest -
actions
protected org.openqa.selenium.interactions.Actions actions -
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
-
js
-
data
-
-
Constructor Details
-
SpectrumEntity
public SpectrumEntity()
-
-
Method Details
-
hover
Hovers on the provided WebElement, leveraging theactions
field- Parameters:
webElement
- the WebElement on which to hover- Returns:
- the calling SpectrumEntity instance
-
screenshot
Adds a screenshot at INFO level to the current test in the Extent Report- Returns:
- the calling SpectrumEntity instance
-
screenshotInfo
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
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
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 logstatus
- the log's status- Returns:
- the generated screenshot
-
deleteDownloadsFolder
public void deleteDownloadsFolder()Deletes the download folder (its path is provided in theconfiguration*.yaml
) -
waitForDownloadOf
Leverages the configurabledownloadWait
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
Leverages thewaitForDownloadOf
method and then compares the checksums of the two files provided.- Parameters:
downloadedFileName
- name of the downloaded filefileToCheckName
- name of the static file to be used as comparison- Returns:
- true if the files are equal
-
checkDownloadedFile
Leverages thewaitForDownloadOf
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'sclear
andsendKeys
on the provided WebElement, which is then returned- Parameters:
webElement
- target WebElementkeysToSend
- keys to send- Returns:
- the target WebElement passed as argument
-
upload
Uploads to the provided WebElement (usually an input field withtype="file"
) the file with the provided name, taken from the configurableruntime.filesFolder
.- Parameters:
webElement
- target WebElementfileName
- 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 providedby
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 providedby
is present in the current page- Parameters:
by
- the WebElement's selector- Returns:
- true if the WebElement is not found
-
hasClass
Checks if the provided WebElement has the provided css class- Parameters:
webElement
- the WebElement to checkclassName
- the css class to look for- Returns:
- true if the WebElement has the provided css class
-
hasClasses
Checks if the provided WebElement has all the provided css classes- Parameters:
webElement
- the WebElement to checkclasses
- the css classes to look for- Returns:
- true if the WebElement has all the provided css classes
-
sha256Of