Improved screenshots

This commit is contained in:
2023-02-24 16:03:33 -06:00
parent 1b3b26bdbb
commit be6d4bb657
3 changed files with 9 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import io.github.bonigarcia.wdm.WebDriverManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
@ -23,6 +24,8 @@ public class QBaseSeleniumTest
protected QSeleniumJavalin qSeleniumJavalin;
protected QSeleniumLib qSeleniumLib;
private int screenshotIndex = 1;
/*******************************************************************************
@ -81,9 +84,9 @@ public class QBaseSeleniumTest
**
*******************************************************************************/
@AfterEach
void afterEach()
void afterEach(TestInfo testInfo)
{
qSeleniumLib.takeScreenshotToFile();
qSeleniumLib.takeScreenshotToFile(getClass().getSimpleName() + "/" + testInfo.getDisplayName());
if(driver != null)
{

View File

@ -345,6 +345,7 @@ public class QSeleniumLib
/*******************************************************************************
** 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)
{
@ -353,7 +354,7 @@ public class QSeleniumLib
try
{
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();
if(destFile.exists())
{

View File

@ -93,7 +93,9 @@ public class SavedFiltersTest extends QBaseSeleniumTest
//////////////////////////////
// click into a view screen //
//////////////////////////////
qSeleniumLib.takeScreenshotToFile("before-johnny-click");
qSeleniumLib.waitForSelectorContaining("DIV", "Jonny").click();
qSeleniumLib.takeScreenshotToFile("after-johnny-click");
qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe");
/////////////////////////////////////////////////////