Screenshot Class
Screenshot object
Constructor
Item Index
Methods
- _browserPadding
- _determineBlockOuts
- _execute
- _gatherSections
- _gatherViewPortSections
- _logMethodCall
- _reduceRectItemToArea
- _requestJSON
- _screenshotPrePrecessing
- _stitchImages
- _takeScreenshot
- _takeSectionScreenshots
- _takeViewPortScreenshot
- _takeViewPortScreenshots
- _validateArea
- _validateRectItem
- areaScreenshot
- documentScreenshot
- getMaxImageResolution
- takeProcessedScreenshot
- takeRawScreenshot
- viewPortScreenshot
Methods
_browserPadding
-
padding
Determines if the screenshots need additional padding
Note: Overwrite this method if you want to implement standard browser padding.
Parameters:
-
padding
Object
_determineBlockOuts
-
area
-
context
-
blockOuts
-
[blockOutColor=black]
Determines the areas that should be blocked-out
Parameters:
Returns:
List of rectangular areas {x, y, width, height}
_execute
-
script
-
[args]
Executes a script in the browser and returns the result.
This is a convenience method for accessing the execute method.
Returns:
_gatherSections
-
area
-
padding
-
initData
-
maxImageResolution
-
needsStitching
Calculates the sections that need to be captured on their own to be able to capture the whole document.
This method depends on the value given to "maxImageResolution".
Parameters:
-
area
ObjectArea to capture
-
padding
ObjectPadding for screenshots
-
viewPort
ObjectPadding for view-port screenshots, ignoring areas of the view-port screenshot
-
top
IntPadding of view-port screenshot from the top -
bottom
IntPadding of view-port screenshot from the bottom -
left
IntPadding of view-port screenshot from the left -
right
IntPadding of view-port screenshot from the right
-
-
screenshot
ObjectPadding for screenshots, ignoring areas of the screenshot
-
top
IntPadding of screenshot from the top -
bottom
IntPadding of screenshot from the bottom -
left
IntPadding of screenshot from the left -
right
IntPadding of screenshot from the right
-
-
-
initData
ObjectData that was initially gathered from the client
-
maxImageResolution
IntMax. number of pixels allowed for a screenshot
-
needsStitching
BooleanDoes the browser need stitching?
Returns:
List of sections
_gatherViewPortSections
-
section
-
padding
-
initData
-
index
Calculates the sections that need to be captured when the browser is not able to return pixels outside of the view-port.
Parameters:
-
section
ObjectSection that should be captured
-
padding
ObjectPadding for screenshots
-
viewPort
ObjectPadding for view-port screenshots, ignoring areas of the view-port screenshot
-
top
IntPadding of view-port screenshot from the top -
bottom
IntPadding of view-port screenshot from the bottom -
left
IntPadding of view-port screenshot from the left -
right
IntPadding of view-port screenshot from the right
-
-
screenshot
ObjectPadding for screenshots, ignoring areas of the screenshot
-
top
IntPadding of screenshot from the top -
bottom
IntPadding of screenshot from the bottom -
left
IntPadding of screenshot from the left -
right
IntPadding of screenshot from the right
-
-
-
initData
ObjectData that was initially gathered from the client
-
index
IntIndex of first view-port
Returns:
_reduceRectItemToArea
-
item
-
area
Reduces a frame-item to a specified area
_requestJSON
-
method
-
path
-
[body]
Performs a context dependent JSON request for the current session. The result is parsed for errors.
Returns:
_screenshotPrePrecessing
-
image
Processes the screenshots before it is used for stitching
Note: Some browser need some pre-processing like rotating the screenshot.
Parameters:
-
image
PNGImageImage to process
Returns:
_stitchImages
-
area
-
sections
-
devicePixelRatio
Stitches all the sections and view-ports together to one final image
Parameters:
Returns:
_takeScreenshot
-
fn
-
[options]
Takes a screenshot of an area that will be specified through the return-value of the callback
Parameters:
-
fn
FunctionFunction to be called to get area to be captured. Supplies the data retrieved from the client as the first parameters.
-
[options]
Object optional-
[horizontalPadding=0]
Int optionalPadding of the document for adjustment
-
[eachFn]
Function optionalWill execute method on client before each screenshot is taken. First parameter is index of screenshot.
-
[completeFn]
Function optionalWill execute method on client after all screenshots are taken.
-
[padding]
Object optionalPadding for screenshots
-
[viewPort]
Object optionalPadding for view-port screenshots, ignoring areas of the view-port screenshot -
[viewPort.top=0]
Int optionalPadding of view-port screenshot from the top -
[viewPort.bottom=0]
Int optionalPadding of view-port screenshot from the bottom -
[viewPort.left=0]
Int optionalPadding of view-port screenshot from the left -
[viewPort.right=0]
Int optionalPadding of view-port screenshot from the right -
[screenshot]
Object optionalPadding for screenshot, ignoring areas of the screenshot -
[screenshot.top=0]
Int optionalPadding of screenshot from the top -
[screenshot.bottom=0]
Int optionalPadding of screenshot from the bottom -
[screenshot.left=0]
Int optionalPadding of screenshot from the left -
[screenshot.right=0]
Int optionalPadding of screenshot from the right -
[document]
Object optionalPadding for document screenshots, ignoring areas of the document screenshot -
[document.top=0]
Int optionalPadding of document screenshot from the top -
[document.bottom=0]
Int optionalPadding of document screenshot from the bottom -
[document.left=0]
Int optionalPadding of document screenshot from the left -
[document.right=0]
Int optionalPadding of document screenshot from the right
-
-
[context]
ActiveWindow | Element optionalContext of screenshot
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
Returns:
_takeSectionScreenshots
-
sections
-
initData
-
[options]
Takes all the screenshots defined in section
_takeViewPortScreenshot
-
section
-
viewPort
-
initData
-
[options]
Takes a screenshot of the given view-port in relation to the section
_takeViewPortScreenshots
-
section
-
viewPorts
-
initData
-
[options]
Takes all the screenshots defined in the view-ports
_validateArea
-
area
-
padding
-
initData
Validates and corrects area that was given to capture
Parameters:
-
area
Object -
padding
ObjectPadding for screenshots
-
viewPort
ObjectPadding for view-port screenshots, ignoring areas of the view-port screenshot
-
top
IntPadding of view-port screenshot from the top -
bottom
IntPadding of view-port screenshot from the bottom -
left
IntPadding of view-port screenshot from the left -
right
IntPadding of view-port screenshot from the right
-
-
screenshot
ObjectPadding for screenshots, ignoring areas of the screenshot
-
top
IntPadding of screenshot from the top -
bottom
IntPadding of screenshot from the bottom -
left
IntPadding of screenshot from the left -
right
IntPadding of screenshot from the right
-
-
document
ObjectPadding for document screenshots, ignoring areas of the document screenshot
-
top
IntPadding of document screenshot from the top -
bottom
IntPadding of document screenshot from the bottom -
left
IntPadding of document screenshot from the left -
right
IntPadding of document screenshot from the right
-
-
-
initData
Object
_validateRectItem
-
item
Calidates if a rectangular item has all the required properties
Parameters:
-
item
Object
areaScreenshot
-
[x=0]
-
[y=0]
-
[width=document.width-x]
-
[height=document.height-y]
-
[options]
Takes a screenshot of a specific area
Parameters:
-
[x=0]
Int optionalX-coordinate for area
-
[y=0]
Int optionalY-coordinate for area
-
[width=document.width-x]
Int optionalWidth of area to be captured
-
[height=document.height-y]
Int optionalHeight of area to be captured
-
[options]
Object optional-
[horizontalPadding=0]
Int optionalPadding of the document for adjustment
-
[eachFn]
Function optionalWill execute method on client before each screenshot is taken. First parameter is index of screenshot.
-
[completeFn]
Function optionalWill execute method on client after all screenshots are taken.
-
[context]
ActiveWindow | Element optionalContext of screenshot
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
Returns:
documentScreenshot
-
[options]
Takes a screenshot of the whole document
Parameters:
-
[options]
Object optional-
[horizontalPadding=0]
Int optionalPadding of the document for adjustment
-
[eachFn]
Function optionalWill execute method on client before each screenshot is taken. First parameter is index of screenshot.
-
[completeFn]
Function optionalWill execute method on client after all screenshots are taken.
-
[context]
ActiveWindow | Element optionalContext of screenshot
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-
Returns:
getMaxImageResolution
()
Int
Gets the max. allowed resolution for one screenshot. If the document exceeds this resolution, then the screenshot will be stitched together from multiple smaller screenshots called sections.
Returns:
takeProcessedScreenshot
-
[options]
Takes a screenshot pre-processed and converted into an image
Parameters:
-
[options]
Object optional
Returns:
takeRawScreenshot
-
[options]
Takes a screenshot as-is from the webdriver protocol
Parameters:
-
[options]
Object optional
Returns:
viewPortScreenshot
-
[options]
Takes a screenshot of the current view-port
Parameters:
-
[options]
Object optional-
[horizontalPadding=0]
Int optionalPadding of the document for adjustment
-
[eachFn]
Function optionalWill execute method on client before each screenshot is taken. First parameter is index of screenshot.
-
[completeFn]
Function optionalWill execute method on client after all screenshots are taken.
-
[context]
ActiveWindow | Element optionalContext of screenshot
-
[blockOuts]
Object[] | Element[] | String[] optionalList of areas/elements that should be blocked-out
-
[blockOutColor=black]
Object optionalColor to be used for blocking-out areas {red, green, blue, alpha}
-
[wait=100]
Int optionalWait in ms before each screenshot
-