mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 05:10:45 +00:00
Improved screenshots
This commit is contained in:
@ -6,6 +6,7 @@ import io.github.bonigarcia.wdm.WebDriverManager;
|
|||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.TestInfo;
|
||||||
import org.openqa.selenium.Dimension;
|
import org.openqa.selenium.Dimension;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.chrome.ChromeDriver;
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
@ -23,6 +24,8 @@ public class QBaseSeleniumTest
|
|||||||
protected QSeleniumJavalin qSeleniumJavalin;
|
protected QSeleniumJavalin qSeleniumJavalin;
|
||||||
protected QSeleniumLib qSeleniumLib;
|
protected QSeleniumLib qSeleniumLib;
|
||||||
|
|
||||||
|
private int screenshotIndex = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -81,9 +84,9 @@ public class QBaseSeleniumTest
|
|||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void afterEach()
|
void afterEach(TestInfo testInfo)
|
||||||
{
|
{
|
||||||
qSeleniumLib.takeScreenshotToFile();
|
qSeleniumLib.takeScreenshotToFile(getClass().getSimpleName() + "/" + testInfo.getDisplayName());
|
||||||
|
|
||||||
if(driver != null)
|
if(driver != null)
|
||||||
{
|
{
|
||||||
|
@ -345,6 +345,7 @@ public class QSeleniumLib
|
|||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Take a screenshot, and give it a path/name of your choosing (under SCREENSHOTS_PATH)
|
** Take a screenshot, and give it a path/name of your choosing (under SCREENSHOTS_PATH)
|
||||||
|
** - note - .png will be appended.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public void takeScreenshotToFile(String filePathSuffix)
|
public void takeScreenshotToFile(String filePathSuffix)
|
||||||
{
|
{
|
||||||
@ -353,7 +354,7 @@ public class QSeleniumLib
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
File outputFile = driver.findElement(By.cssSelector("html")).getScreenshotAs(OutputType.FILE);
|
File outputFile = driver.findElement(By.cssSelector("html")).getScreenshotAs(OutputType.FILE);
|
||||||
File destFile = new File(SCREENSHOTS_PATH + filePathSuffix);
|
File destFile = new File(SCREENSHOTS_PATH + filePathSuffix + ".png");
|
||||||
destFile.mkdirs();
|
destFile.mkdirs();
|
||||||
if(destFile.exists())
|
if(destFile.exists())
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,9 @@ public class SavedFiltersTest extends QBaseSeleniumTest
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// click into a view screen //
|
// click into a view screen //
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
qSeleniumLib.takeScreenshotToFile("before-johnny-click");
|
||||||
qSeleniumLib.waitForSelectorContaining("DIV", "Jonny").click();
|
qSeleniumLib.waitForSelectorContaining("DIV", "Jonny").click();
|
||||||
|
qSeleniumLib.takeScreenshotToFile("after-johnny-click");
|
||||||
qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe");
|
qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe");
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user