public class ScreenshotHandler extends DocImageHandler
Takes screenshot of pages using a Selenium WebDriver
.
Either the entire page, or a specific DOM element.
Screenshot images can be stored in a document metadata/field or
in a local directory.
<cssSelector>(Optional selector of element to capture.)</cssSelector>
<targets>[metadata|directory] (One or both, separated by comma.)</targets>
<imageFormat>(Image format. Default is "png".)</imageFormat>
<!-- The following applies to the "directory" target: -->
<targetDir
field="(Document field to store the local path to the image.)"
structure="[url2path|date|datetime]">
(Local directory where to save images.)
</targetDir>
<!-- The following applies to the "metadata" target: -->
<targetMetaField>(Document field where to store the image.)</targetMetaField>
The above XML configurable options can be nested in a supporting parent tag of any name. The expected parent tag name is defined by the consuming classes (e.g. "screenshot").
DocImageHandler.DirStructure, DocImageHandler.Target
Modifier and Type | Field and Description |
---|---|
static Path |
DEFAULT_SCREENSHOT_DIR |
static String |
DEFAULT_SCREENSHOT_DIR_FIELD |
static String |
DEFAULT_SCREENSHOT_META_FIELD |
DEFAULT_IMAGE_FORMAT, DEFAULT_TYPES
Constructor and Description |
---|
ScreenshotHandler() |
ScreenshotHandler(CachedStreamFactory streamFactory) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
String |
getCssSelector() |
int |
hashCode() |
void |
loadFromXML(XML xml) |
void |
saveToXML(XML xml) |
void |
setCssSelector(String cssSelector) |
void |
takeScreenshot(org.openqa.selenium.WebDriver driver,
Doc doc) |
String |
toString() |
getImageFormat, getTargetDir, getTargetDirField, getTargetDirStructure, getTargetMetaField, getTargets, handleImage, setImageFormat, setTargetDir, setTargetDirField, setTargetDirStructure, setTargetMetaField, setTargets, setTargets
public static final Path DEFAULT_SCREENSHOT_DIR
public static final String DEFAULT_SCREENSHOT_DIR_FIELD
public static final String DEFAULT_SCREENSHOT_META_FIELD
public ScreenshotHandler()
public ScreenshotHandler(CachedStreamFactory streamFactory)
public String getCssSelector()
public void setCssSelector(String cssSelector)
public void takeScreenshot(org.openqa.selenium.WebDriver driver, Doc doc)
public void loadFromXML(XML xml)
loadFromXML
in interface IXMLConfigurable
loadFromXML
in class DocImageHandler
public void saveToXML(XML xml)
saveToXML
in interface IXMLConfigurable
saveToXML
in class DocImageHandler
public boolean equals(Object other)
equals
in class DocImageHandler
public int hashCode()
hashCode
in class DocImageHandler
public String toString()
toString
in class DocImageHandler
Copyright © 2009–2023 Norconex Inc.. All rights reserved.