0.14.0
Abstract base class for Scriptor scripts.
(string)
Name of the script
(string)
Version of the script (in
semantic versioning
:
"major.minor.patch")
Runs this script.
See Developing Own Scripts in the README.
(Object)
An object containing a Playwright
BrowserContext for each directory in either the script or input directory's
contexts directory, with the respective directory name as key; or a
BrowserContext under
files.BROWSER_CONTEXT_DEFAULT
if no such directory exists
(string)
The directory that contains the Script.js
and other run-independent files for the script (read-only)
(string)
The directory to which all output of the
script run should be written to (read-write)
Promise<boolean>
:
Whether the script could be called again with the
output directory as a new input directory
Static functions to work with the Scriptor directory structure.
Name of the directory in the script, input, or output directories that contains serialized data for each browser context.
The directory contains one directory for each available browser context, with the name of that directory being the context name.
Type: string
Browser context name that is used if no browser context has been declared.
Type: string
Name of the JSON file in a browser context directory that contains the browser context options used by Playwright.
Type: string
Name of the file in the output directory that is a copy of the input directory's ID file.
Type: string
Name of the main script options file in the input directory.
Type: string
Name of the directory to store log files that are not browser context dependent.
Type: string
Gets the paths of all existing files with the specified file name in each of the the base directories (or the respective browser context directory).
(string)
Name of the file to check for
Array<string>
:
The paths of the existing files
Gets the browser context directory for a specific browser context.
(string)
The name of the browser context
(string)
The base directory (script, input, or output)
that contains the browser context directory
string
:
The path of the respective browser context directory
(may not exist)
Reads and combines options (objects) from JSON files.
A typical code sequence to read the options for a script is:
(Object
= {}
)
The default options that are returned if not
(property-wise) overwritten from the files
Object
:
The options
const defaultScriptOptions = { ... };
const requiredScriptOptions = [ ... ];
const scriptOptions = files.readOptions(files.getExisting(
files.SCRIPT_OPTIONS_FILE_NAME, [ scriptDirectory, inputDirectory ]),
defaultScriptOptions, requiredScriptOptions);
Static functions to modify a Playwright page object or get its status.
Contains the file names used by takeSnapshot for the respective snapshot output files.
Type: Object
Contains the default options for each snapshot function.
Type: Object
Default options for adjustViewportToPage.
Type: Object
Adjusts the viewports to the current web page according to the options.
By default options, the viewport may only be enlarged.
(Object
= {}
)
Limits the adjustment, overwriting
VIEWPORT_ADJUST_DEFAULT_OPTIONS
,
or
false
to not adjust at all.
Name | Description |
---|---|
options.widthEnlarge boolean
(default false )
|
Whether to enlarge the viewport width if the page is larger than the viewport |
options.widthReduce boolean
(default false )
|
Whether to reduce the viewport width if the page is smaller than the viewport |
options.widthMinimum number
(default 360 )
|
The minimum integer number of pixels to reduce the viewport width to (only considered when reducing the viewport width) |
options.widthMaximum number
(default Number.MAX_SAFE_INTEGER )
|
The maximum integer number of pixels to enlarge the viewport width to (only considered when enlarging the viewport width) |
options.heightEnlarge boolean
(default true )
|
Whether to enlarge the viewport height if the page is larger than the viewport |
options.heightReduce boolean
(default false )
|
Whether to reduce the viewport height if the page is smaller than the viewport |
options.heightMinimum number
(default 360 )
|
The minimum integer number of pixels to reduce the viewport height to (only considered when reducing the viewport height) |
options.heightMaximum number
(default Number.MAX_SAFE_INTEGER )
|
The maximum integer number of pixels to enlarge the viewport height to (only considered when enlarging the viewport height) |
Promise<boolean>
:
Whether the viewport was changed
Gets the height of the page's body element in pixels, including content not visible on the screen due to overflow.
Promise<number>
:
The height in pixels
Gets the width of the page's body element in pixels, including content not visible on the screen due to overflow.
Promise<number>
:
The width in pixels
Waits until there are no network connections for at least 500 ms, but at most until the timeout.
(number)
Maximum wait time in milliseconds, use 0 for no
timeout
Promise<void>
:
A promise to wait on
Takes a snapshot of the screen and viewport coordinates, the DOM (structure), and information on each DOM node.
(object
= {}
)
Each snapshot-specific options can overwrite a
generic
path
and can be
false
(instead of an object) to disable the
respective snapshot
Name | Description |
---|---|
options.path string?
|
The directory to store the snapshot in (will be created if it does not exist) |
options.dom object?
|
Options for takeDomSnapshot |
options.nodes object?
|
Options for takeNodesSnapshot |
options.screenshot object?
|
Options for takeScreenshot |
options.viewport object?
|
Options for takeViewportSnapshot |
Promise<(object | false
)>
:
Contains a property per snapshot with the return value of
the respective snapshot function as value
Takes a snapshot of all DOM nodes.
Promise<(array<object> | false
)>
:
The nodes with these properties:
undefined
if the attribute is not setx
, y
,
width
, and height
(like
takeViewportSnapshot)options.addElementText = false
)options.addAttributes = false
)options.addCss = false
)Or false
if options
is false
Takes a screenshot of the page.
(object
= {}
)
Options for taking the screenshot (or
false
to take none), which are passed to Playwright's
screenshot
function
Promise<(Buffer | false
)>
:
The screenshot as buffered image or
false
if
options
is
false
Takes a snapshot of the viewport position.
Promise<(Object | false
)>
:
The snapshot with following properties:
Or false
if options
is false
The Bunyan log object that Scriptor uses.
const { log } = require("@webis-de/scriptor");
log.info({foo: "bar", answer: 42}, "example.logging");
Current version of Scriptor