com.nordstrom.automation.selenium.junit.ScreenshotArtifact Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium3-foundation Show documentation
Show all versions of selenium3-foundation Show documentation
Selenium3 Foundation is an automation framework designed to extend and enhance the capabilities provided by Selenium 3.0 (WebDriver).
package com.nordstrom.automation.selenium.junit;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.nordstrom.automation.selenium.core.DriverManager;
import com.nordstrom.automation.selenium.utility.ScreenshotUtils;
import com.nordstrom.automation.junit.ArtifactType;
/**
* This class implements the artifact type for screenshot capture.
*/
public class ScreenshotArtifact implements ArtifactType {
private static final Path ARTIFACT_PATH = Paths.get("screenshots");
private static final String EXTENSION = "png";
private static final Logger LOGGER = LoggerFactory.getLogger(ScreenshotArtifact.class);
/**
* {@inheritDoc}
*/
@Override
public boolean canGetArtifact(Object instance) {
Optional optDriver = DriverManager.nabDriver(instance);
return ScreenshotUtils.canGetArtifact(optDriver, LOGGER);
}
/**
* {@inheritDoc}
*/
@Override
public byte[] getArtifact(Object instance, Throwable reason) {
Optional optDriver = DriverManager.nabDriver(instance);
return ScreenshotUtils.getArtifact(optDriver, reason, LOGGER);
}
/**
* {@inheritDoc}
*/
@Override
public Path getArtifactPath(Object instance) {
return ArtifactType.super.getArtifactPath(instance).resolve(ARTIFACT_PATH);
}
/**
* {@inheritDoc}
*/
@Override
public String getArtifactExtension() {
return EXTENSION;
}
/**
* {@inheritDoc}
*/
@Override
public Logger getLogger() {
return LOGGER;
}
}