All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nordstrom.automation.selenium.junit.ScreenshotArtifact Maven / Gradle / Ivy

Go to download

Selenium3 Foundation is an automation framework designed to extend and enhance the capabilities provided by Selenium 3.0 (WebDriver).

There is a newer version: 1.0.4
Show newest version
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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy