Class ScreenshotHandler
- java.lang.Object
-
- com.norconex.collector.http.fetch.util.DocImageHandler
-
- com.norconex.collector.http.fetch.impl.webdriver.ScreenshotHandler
-
- All Implemented Interfaces:
IXMLConfigurable
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.XML configuration usage:
<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").
- Since:
- 3.0.0
- Author:
- Pascal Essiembre
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.norconex.collector.http.fetch.util.DocImageHandler
DocImageHandler.DirStructure, DocImageHandler.Target
-
-
Field Summary
Fields Modifier and Type Field Description static PathDEFAULT_SCREENSHOT_DIRstatic StringDEFAULT_SCREENSHOT_DIR_FIELDstatic StringDEFAULT_SCREENSHOT_META_FIELD-
Fields inherited from class com.norconex.collector.http.fetch.util.DocImageHandler
DEFAULT_IMAGE_FORMAT, DEFAULT_TYPES
-
-
Constructor Summary
Constructors Constructor Description ScreenshotHandler()ScreenshotHandler(CachedStreamFactory streamFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)StringgetCssSelector()inthashCode()voidloadFromXML(XML xml)voidsaveToXML(XML xml)voidsetCssSelector(String cssSelector)voidtakeScreenshot(org.openqa.selenium.WebDriver driver, Doc doc)StringtoString()-
Methods inherited from class com.norconex.collector.http.fetch.util.DocImageHandler
getImageFormat, getTargetDir, getTargetDirField, getTargetDirStructure, getTargetMetaField, getTargets, handleImage, setImageFormat, setTargetDir, setTargetDirField, setTargetDirStructure, setTargetMetaField, setTargets, setTargets
-
-
-
-
Field Detail
-
DEFAULT_SCREENSHOT_DIR
public static final Path DEFAULT_SCREENSHOT_DIR
-
DEFAULT_SCREENSHOT_DIR_FIELD
public static final String DEFAULT_SCREENSHOT_DIR_FIELD
- See Also:
- Constant Field Values
-
DEFAULT_SCREENSHOT_META_FIELD
public static final String DEFAULT_SCREENSHOT_META_FIELD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ScreenshotHandler
public ScreenshotHandler()
-
ScreenshotHandler
public ScreenshotHandler(CachedStreamFactory streamFactory)
-
-
Method Detail
-
getCssSelector
public String getCssSelector()
-
setCssSelector
public void setCssSelector(String cssSelector)
-
takeScreenshot
public void takeScreenshot(org.openqa.selenium.WebDriver driver, Doc doc)
-
loadFromXML
public void loadFromXML(XML xml)
- Specified by:
loadFromXMLin interfaceIXMLConfigurable- Overrides:
loadFromXMLin classDocImageHandler
-
saveToXML
public void saveToXML(XML xml)
- Specified by:
saveToXMLin interfaceIXMLConfigurable- Overrides:
saveToXMLin classDocImageHandler
-
equals
public boolean equals(Object other)
- Overrides:
equalsin classDocImageHandler
-
hashCode
public int hashCode()
- Overrides:
hashCodein classDocImageHandler
-
toString
public String toString()
- Overrides:
toStringin classDocImageHandler
-
-