API
Classes
It manages the use of environment variables by providing useful methods for checking and obtaining the variables.
Provides Puppeteer initialization by creating Browser and Page instances to provide the browser context necessary for the execution of a custom function.
Environment
It manages the use of environment variables by providing useful methods for checking and obtaining the variables.
Kind: global class
static
.is(environment) ⇒
boolean
.has(variable) ⇒
boolean
.get(variable) ⇒
string
|Array
|object
|null
environment.PRODUCTION
Value of the variable defined by the NodeJS processor to identify the Production execution environment.
Kind: instance property of Environment
environment.IMPRESSIONIST_VERSION
The current version of the library. It can be used, for example, for bug reporting plugins.
Kind: instance property of Environment
Environment.is(environment) ⇒ boolean
boolean
Check if a specific environment is running. i.e prod or dev.
Kind: static method of Environment
Returns: boolean
- Result true or false.
Param | Type | Description |
---|---|---|
environment |
| Identifier of the ENV environment variable. For example, prod, dev, etc. |
Example
Environment.has(variable) ⇒ boolean
boolean
Check if a specific environment variable exists.
Kind: static method of Environment
Returns: boolean
- Result true or false.
Param | Type | Description |
---|---|---|
variable |
| The variable to check. |
Example
Environment.get(variable) ⇒ string
| Array
| object
| null
string
| Array
| object
| null
Return a specific env var. If not exist return null.
Kind: static method of Environment
Param | Type | Description |
---|---|---|
variable |
| The variable to extract. |
Example
Process
Provides Puppeteer initialization by creating Browser and Page instances to provide the browser context necessary for the execution of a custom function.
Kind: global class Summary: Initialize Puppeteer.
instance
static
.execute(url, customFunction, options) ⇒
Promise
.initialize(url, [browserOptions]) ⇒
Promise.<symbol>
.executeFunction(connectionIdentifier, customFunction) ⇒
Promise.<any>
.handleError(error, connectionIdentifier) ⇒
Promise.<any>
.close(connectionIdentifier) ⇒
Promise.<any>
.connect(browserWSEndpoint, customFunction, [...args]) ⇒
Promise.<any>
process.browserController
Provides methods and features to interact with the browser. By default, PuppeteerController.
Kind: instance property of Process
Process.execute(url, customFunction, options) ⇒ Promise
Promise
It provides the necessary context to run a function in the puppeteer or browser context by executing a series of steps, such as initializing a Browser instance and applying extra configurations defined by an input parameter, initializing a Page instance and applying default configurations to it so that the Impressionist library can be used in the browser context of that specific instance.
Kind: static method of Process
Returns: Promise
- Promise object that represents the result of the custom function.
Param | Type | Description |
---|---|---|
url |
| Target URL for scraping process. |
customFunction |
| Custom function to be executed in the Puppeteer context. Like customFunction(browser, page, ...args) { ... }. |
options |
| Options to configure the browser and page. Please check the browser configuration in https://pptr.dev/api/puppeteer.puppeteerlaunchoptions Please check the page navigation options in https://pptr.dev/api/puppeteer.page.goto. |
Example (Basic Usage)
Example (Enabling Browser User Interface)
Example (Set a specific page navigation timeout)
Process.initialize(url, [browserOptions]) ⇒ Promise.<symbol>
Promise.<symbol>
Perform actions to initialize a connection to a page using the browser controller.
Kind: static method of Process
Returns: Promise.<symbol>
- Promise which resolves to a connection identifier.
Param | Type | Default | Description |
---|---|---|---|
url |
| URL or browser Endpoint. | |
[browserOptions] |
|
| Options to configure the browser controller. |
Process.configureConnection(connectionIdentifier)
Configure a page connection.
Kind: static method of Process
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.enableImpressionistFeatures(connectionIdentifier)
Enable all the Impressionist features to be used in the browser context.
Kind: static method of Process
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.executeFunction(connectionIdentifier, customFunction) ⇒ Promise.<any>
Promise.<any>
Execute the function in the browser context provided by the browser controller.
Kind: static method of Process
Returns: Promise.<any>
- Promise which resolves to the result of the execution of the function.
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
customFunction |
| Custom function to be executed in the Puppeteer context. Like customFunction(browser, page, ...args) { ... }. |
Process.handleError(error, connectionIdentifier) ⇒ Promise.<any>
Promise.<any>
Handle errors.
Kind: static method of Process
Returns: Promise.<any>
- Promise which resolves to any result of error handling.
Param | Type | Description |
---|---|---|
error |
| Error object. |
connectionIdentifier |
| Unique identifier for a page connection. |
Process.close(connectionIdentifier) ⇒ Promise.<any>
Promise.<any>
Close connections.
Kind: static method of Process
Returns: Promise.<any>
- Promise which resolves to any result of closing connections.
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.exposeLogger(connectionIdentifier)
Exposes the logger function to be used in the browser context.
Kind: static method of Process
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.enableCollector(connectionIdentifier)
Load the library classes in the browser environment.
Kind: static method of Process
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.registerSelectors(connectionIdentifier)
Make the registration of Selectable sub-classes using their static method register.
Kind: static method of Process
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.registerStrategies(connectionIdentifier)
Register strategies.
Kind: static method of Process
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.addProxyFunctions(connectionIdentifier)
Add functions to be used in Browser Context.
Kind: static method of Process
Param | Type | Description |
---|---|---|
connectionIdentifier |
| Unique identifier for a page connection. |
Process.connect(browserWSEndpoint, customFunction, [...args]) ⇒ Promise.<any>
Promise.<any>
Execute a function in a specific browser endpoint.
Kind: static method of Process
Returns: Promise.<any>
- Promise object that represents the result of the custom function.
Param | Type | Default | Description |
---|---|---|---|
browserWSEndpoint |
| ||
customFunction |
| Custom function to be executed in the Puppeteer context. Like customFunction(browser, page, ...args) { ... }. | |
[...args] |
|
| Any parameter necessary for the custom function. |
Process.setBrowserController(browserController)
Set a browser controller which Impressionist use to interact with the browser context.
Kind: static method of Process
Param | Type | Description |
---|---|---|
browserController |
| Browser controller. |
Process.loadPlugin(plugin)
Load a plugin.
Kind: static method of Process
Param | Type | Description |
---|---|---|
plugin |
| A class to extends or modify the Impressionist behavior. |
Classes
Controls access to puppeteer methods and features.
Provides shorcut methods to Puppeteer configurations for initialize
Log on each of the subscribed monitoring tools.
Initialize Pino and expose its functionality for login.
Provides an interface for Sentry integration with Puppeteerist.
Functions
Add the necessary tags for Sentry. Some come from environment variables and others are defined by the library locally.
Puppeteer
Controls access to puppeteer methods and features.
Kind: global class
Puppeteer.launch([options]) ⇒ Promise.<object>
Promise.<object>
Enables a connection to control the browser.
Kind: static method of Puppeteer
Returns: Promise.<object>
- Promise which resolves to browser instance.
Param | Type | Default | Description |
---|---|---|---|
[options] |
|
| Please read the documentation about the Launch Options. |
Puppeteer.newPage(browser) ⇒ Promise.<object>
Promise.<object>
Create a new Page object.
Kind: static method of Puppeteer
Returns: Promise.<object>
- Promise which resolves to a new Page object. The Page is created in a default browser context.
Param | Type | Description |
---|---|---|
browser |
| Browser instance. |
Puppeteer.close(...controllers)
Close any instance of Page or Browser.
Kind: static method of Puppeteer
Param | Type | Description |
---|---|---|
...controllers |
| Page or Browser instances. |
Puppeteer.goto(page, url)
Navigate to a specific URL.
Kind: static method of Puppeteer
Param | Type | Description |
---|---|---|
page |
| Page instance. |
url |
| URL. |
Puppeteer.evaluate(page, pageFunction, ...args) ⇒ Promise.<any>
Promise.<any>
Execute a function in the browser context.
Kind: static method of Puppeteer
Returns: Promise.<any>
- Promise which resolves to a result of the function executed in the browser context.
Param | Type | Description |
---|---|---|
page |
| Page instance. |
pageFunction |
| A function to be executed in the browser context. |
...args |
| Function arguments. |
Puppeteer.exposeFunction(page, name, puppeteerFunction)
Expose a NodeJS function to be called from the browser context.
Kind: static method of Puppeteer
Param | Type | Description |
---|---|---|
page |
| Page Instance. |
name |
| Function name to be called from the browser context. |
puppeteerFunction |
| Function that is going to be executed in the NodeJS context. |
Puppeteer.addScriptTag(page, options)
Add a new script tag in the HTML layout.
Kind: static method of Puppeteer
Param | Type | Description |
---|---|---|
page |
| Page instance. |
options |
| Options for load content in the script tag. Please check the documentation. |
Puppeteer.addEventListener(page, method, event, handler)
Add an event listener to page.
Kind: static method of Puppeteer
Param | Type | Description |
---|---|---|
page |
| Page instance. |
method |
| EventEmitter method. |
event |
| The event to add the handler to. |
handler |
| The event listener that will be added. |
PuppeteerController
Provides shorcut methods to Puppeteer configurations for initialize
Kind: global class
static
.initialize(url, [options]) ⇒
Promise.<symbol>
.evaluate(identifier, pageFunction, ...args) ⇒
Promise.<any>
.execute(identifier, puppeteerFunction) ⇒
Promise.<any>
puppeteerController.browser
Browser instance.
Kind: instance property of PuppeteerController
puppeteerController.pages
Page instances.
Kind: instance property of PuppeteerController
PuppeteerController.initialize(url, [options]) ⇒ Promise.<symbol>
Promise.<symbol>
Open a connection to an URL using a page instance.
Kind: static method of PuppeteerController
Returns: Promise.<symbol>
- Promise which resolves to a unique identifier represented by a Symbol.
Param | Type | Description |
---|---|---|
url |
| URL. |
[options] |
| Please read the documentation about the Launch Options. |
PuppeteerController.close([identifier])
Close connections.
Kind: static method of PuppeteerController
Param | Type | Description |
---|---|---|
[identifier] |
| Unique identifier for a page connection. |
PuppeteerController.evaluate(identifier, pageFunction, ...args) ⇒ Promise.<any>
Promise.<any>
Evaluate a function in a specific page.
Kind: static method of PuppeteerController
Returns: Promise.<any>
- Promise which resolves to the result of the pageFunction.
Param | Type | Description |
---|---|---|
identifier |
| Unique identifier for a page connection. |
pageFunction |
| A function to be evaluated in the browser context. |
...args |
| Arguments for being passed to the pageFunction. |
PuppeteerController.execute(identifier, puppeteerFunction) ⇒ Promise.<any>
Promise.<any>
Execute a function which provides browser and page as parameters.
Kind: static method of PuppeteerController
Returns: Promise.<any>
- Promise which resolves to the result of the puppeteerFunction.
Param | Type | Description |
---|---|---|
identifier |
| Unique identifier for a page connection. |
puppeteerFunction |
| Custom function. |
PuppeteerController.inject(identifier, functionality)
Inject a function in the HTML layout.
Kind: static method of PuppeteerController
Param | Type | Description |
---|---|---|
identifier |
| Unique identifier for a page connection. |
functionality |
| Function to be load as a script tag in the page. |
PuppeteerController.expose(identifier, functionality, [name])
Expose a NodeJS function to be used from the browser context.
Kind: static method of PuppeteerController
Param | Type | Default | Description |
---|---|---|---|
identifier |
| Unique identifier for a page connection. | |
functionality |
| Function to be exposed. | |
[name] |
|
| Function name to be used in the browserContext. |
PuppeteerController.enableProxy(identifier, proxy)
Setting proxies per page basis.
Kind: static method of PuppeteerController
Param | Type | Description |
---|---|---|
identifier |
| Unique identifier for a page connection. |
proxy |
| Proxy to use in the current page. Must begin with a protocol e.g. http://, https://, socks://. |
PuppeteerController.enableDebugMode(identifier)
Display console.log messages in environments different than Production.
Kind: static method of PuppeteerController
Param | Type | Description |
---|---|---|
identifier |
| Unique identifier for a page connection. |
MonitorManager
Log on each of the subscribed monitoring tools.
Kind: global class
MonitorManager.log(report)
Register a report.
Kind: static method of MonitorManager
Param | Type | Description |
---|---|---|
report |
| Information to be logged in. |
MonitorManager.subscribe(logger)
Subscribe to a monitoring or logging tool.
Kind: static method of MonitorManager
Param | Type | Description |
---|---|---|
logger |
| Monitoring or logging tool. |
MonitorManager.unsubscribe(logger)
Unsubscribe to a monitoring or logging tool.
Kind: static method of MonitorManager
Param | Type | Description |
---|---|---|
logger |
| Monitoring or logging tool. |
MonitorManager.clear()
Delete all logers. It can be used to discard the default loggers.
Kind: static method of MonitorManager
Pino
Initialize Pino and expose its functionality for login.
Kind: global class
Pino.log(report)
Log a report.
Kind: static method of Pino
Param | Type | Description |
---|---|---|
report |
| Information that will be used to compose the report. |
Sentry
Provides an interface for Sentry integration with Puppeteerist.
Kind: global class
.sendException(error) ⇒
Promise.<void>
Sentry.initialize(options, tags)
Specifies the basic options for Sentry initialization.
Kind: static method of Sentry
Param | Type | Description |
---|---|---|
options |
| Please check Sentry documentation. |
tags |
| Set of tags. |
Sentry.log(report)
Log a report.
Kind: static method of Sentry
Param | Type | Description |
---|---|---|
report |
| Information that will be used to compose the report. |
Sentry.sendException(error) ⇒ Promise.<void>
Promise.<void>
Send error generated to Sentry while Puppeteer execution.
Kind: static method of Sentry
Returns: Promise.<void>
- Promise object that represents end of the Sentry actions.
Param | Type | Description |
---|---|---|
error |
| Object that represents the error generated during the execution of the scraper. |
Sentry.()
Add the necessary tags for Sentry. Some come from environment variables and others are defined by the library locally.
Kind: global function
Classes
Collect items from a Collection by being iterated through a context element.
It provides a data structure to control the context, which is an object with two properties. The first is document, which refers to the document object present in the browser context. If the context is not running in Browser context then document is set to null. The other property is element, which stores an element that will be used by some instance during the execution of the collectable tree.
Custom error to be used by the QuerySelector class in case an element or series of elements does not exist in the DOM.
Custom error to be used by the Collectable class to identify if the error was created by the error or require methods of the same class.
Custom error to be used by the Collectable class to return any error caused in the execution of the Collectable tree and that does not have a Collectable default method specified.
Log useful information and register errors.
Provides a common method to share across the different strategies managers.
Provides a static method that checks the data type of an incoming value.
Loads all DOM elements that are handled by a LazyLoad.
Handles the pagination of an HTML section.
Functions
Logger.(elements) ⇒ Array.<object>
Extract useful information from elements and give them a specific format inside a list.
clickAndWait(elementSelector, waitFor)
Click an element in the DOM and then wait for another event like a timeout, a selector being loading in the DOM or wait for the completion of an asyncronous function.
Collector
Collect items from a Collection by being iterated through a context element.
Kind: global class
new Collector(contextAccessor, collection)
Param | Type | Description |
---|---|---|
contextAccessor |
| Objects that returns an iterable object as a result of its execution. |
collection |
| A collection instance. |
collector.iterationQuery
Queries to append in iterate method.
Kind: instance property of Collector
collector.call(context) ⇒ Promise.<Array>
Promise.<Array>
Execute the collector.
Kind: instance method of Collector
Returns: Promise.<Array>
- An object that represents a promise for the collected items.
Param | Type | Description |
---|---|---|
context | Object that represents the context or the element that is being passed on nested queries or instances executions. |
Example
collector.iterate(queries) ⇒ Collector
Collector
Creates a new Collector that have a custom accessor and a collection.
Kind: instance method of Collector
Returns: Collector
- A Collector instance.
Param | Type | Description |
---|---|---|
queries |
| A set of queries or callable objects. |
Example
Context
It provides a data structure to control the context, which is an object with two properties. The first is document, which refers to the document object present in the browser context. If the context is not running in Browser context then document is set to null. The other property is element, which stores an element that will be used by some instance during the execution of the collectable tree.
Kind: global class Summary: Create an object to give context to instance executions.
.getElement() ⇒
string
|Array
|Object
context.clone() ⇒ Context
Context
Create a new instance of the same class and assign the values of the object from which it was created. The reason for this method is that the values of the element property can be updated or modified without affecting the original context object, since the new instance is a completely independent object from the original one. Something that does not happen with a simple copy of objects.
Kind: instance method of Context
Summary: Clones a context instance.
Returns: Context
- Object that represents the context or the element that is being passed on nested instances executions.
Example (Clone an existing Context instance.)
context.update(element) ⇒ Context
Context
Update the context object by adding a new value for the element property. First, clone the existing Context object using the clone () method and then update the value of element.
Kind: instance method of Context
Summary: Update the Context object.
Returns: Context
- Object that represents the context or the element that is being passed on nested instances executions.
Param | Type | Description |
---|---|---|
element |
| Stores an element that will be used by some instance during the execution of the collectable tree. |
Example (Update an existing Context instance.)
context.getElement() ⇒ string
| Array
| Object
string
| Array
| Object
Gets the value of the element property. If element is equal to null then it will return the value of the document property.
Kind: instance method of Context
Returns: string
| Array
| Object
- an element that will be used by some instance during the execution of the collectable tree.
Example (Getting the node to be used for nested executions)
SelectorError
Custom error to be used by the QuerySelector class in case an element or series of elements does not exist in the DOM.
Kind: global class
new SelectorError(selector)
Param | Type | Description |
---|---|---|
selector |
|
CustomError
Custom error to be used by the Collectable class to identify if the error was created by the error or require methods of the same class.
Kind: global class
new CustomError(message)
Param | Type | Description |
---|---|---|
message |
| Custom message. |
CollectableError
Custom error to be used by the Collectable class to return any error caused in the execution of the Collectable tree and that does not have a Collectable default method specified.
Kind: global class
new CollectableError(message, history)
Param | Type | Description |
---|---|---|
message |
| Custom message |
history |
| An array of messages of previous executions in the collectable chain. |
Logger
Log useful information and register errors.
Kind: global class
Logger.error(origin, message)
Error level.
Kind: static method of Logger
Param | Type | Description |
---|---|---|
origin |
| Name of the class, function of where the log comes from. |
message |
| Message. |
Logger.warn(origin, elements, message)
Warn level.
Kind: static method of Logger
Param | Type | Description |
---|---|---|
origin |
| Name of the class, function of where the log comes from. |
elements |
| Any element to record its value, data type and instance. |
message |
| Message |
Logger.info(origin, elements, message)
Info level.
Kind: static method of Logger
Param | Type | Description |
---|---|---|
origin |
| Name of the class, function of where the log comes from. |
elements |
| Any element to record its value, data type and instance. |
message |
| Message |
Logger.debug(origin, elements, message)
Debug level.
Kind: static method of Logger
Param | Type | Description |
---|---|---|
origin |
| Name of the class, function of where the log comes from. |
elements |
| Any element to record its value, data type and instance. |
message |
| Message |
StrategyManager
Provides a common method to share across the different strategies managers.
Kind: global class
StrategyManager.lookUp(element, strategies) ⇒ Promise.<object>
Promise.<object>
Search or look up the best strategy.
Kind: static method of StrategyManager
Returns: Promise.<object>
- An object that represents a promise for a specific strategy.
Param | Type | Description |
---|---|---|
element |
| A criterion to be evaluated. |
strategies |
| Available strategies. |
TypeValidator
Provides a static method that checks the data type of an incoming value.
Kind: global class
.check(value, [type]) ⇒
Error
|void
TypeValidator.check(value, [type]) ⇒ Error
| void
Error
| void
Check the entry value if its data type of instance is the same than the type argument.
Kind: static method of TypeValidator
Returns: Error
| void
- - Throws an error if the type does not match the value's data type.
Param | Type | Default | Description |
---|---|---|---|
value |
| Any value for which want to check the data type. | |
[type] |
|
| Data Type: string, number, array, object, boolean, function, CollectionCollector, Collector, NodeCollector. |
Example (Checking if values is String)
Example (Checking if value is Number)
TypeValidator.deepCheck(value, type)
Check recursively if he entry value if its data type of instance is the same than the type argument.
Kind: static method of TypeValidator
Param | Type | Description |
---|---|---|
value |
| Any value for which want to check the data type. |
type |
| Data Type: string, number, array, object, boolean, function, CollectionCollector, Collector, NodeCollector. //TODO: Examples. |
LazyLoadHandler
Loads all DOM elements that are handled by a LazyLoad.
Kind: global class
LazyLoadHandler.execute(buttonSelector, [stopLoad])
Executes the loading of all the elements by providing a clickable element selector, for example, a button.
Kind: static method of LazyLoadHandler
Param | Type | Default | Description |
---|---|---|---|
buttonSelector |
| CSS Selector that represents a button. | |
[stopLoad] |
|
| A function that returns a boolean to control when the event needs to be stopped. By default function is |
Pagination
Handles the pagination of an HTML section.
Kind: global class
Pagination.execute(buttonSelector, waitFor, [stopLoad])
Create a generator object with the new rendered document.
Kind: static method of Pagination
Param | Type | Default | Description |
---|---|---|---|
buttonSelector |
| CSS selector of the button that triggers the action to go to the next pagination. | |
waitFor |
| Selector of an element and timeout in milliseconds to wait for. | |
waitFor.timeout |
| The number of milliseconds to wait for. | |
waitFor.selector |
| A selector of an element to wait for. | |
waitFor.customFunction |
| A function that performs others waiting processes. | |
[stopLoad] |
|
| A function that returns a boolean to control when the event needs to be stopped. By default function is |
Logger.(elements) ⇒ Array.<object>
Array.<object>
Extract useful information from elements and give them a specific format inside a list.
Kind: global function
Returns: Array.<object>
- - List of objects that represent an element.
Param | Type | Description |
---|---|---|
elements |
| Any element to record its value, data type and instance. |
clickAndWait(elementSelector, waitFor)
Click an element in the DOM and then wait for another event like a timeout, a selector being loading in the DOM or wait for the completion of an asyncronous function.
Kind: global function
Param | Type | Description |
---|---|---|
elementSelector |
| CSS Selector to click on. |
waitFor |
| Options to wait for. |
waitFor.timeout |
| Timeout. |
waitFor.selector |
| A CSS Selector. |
waitFor.customFunction |
| A function that performs others waiting processes. |
Classes
Execute a set of queries.
Iterates over each item in context created by a collection, returning it to be collected upon.
Default ContextAcessor, used when there is not contextProcessor in Collector.
Create a Collector instance for collecting a collection for each iterable item in the context.
Creates a Collector instance that returns a NodeList of DOM elements.
Creates a Collector instance that returns a list of combinations generated by Options intances.
Creates an iterable object from a series of options and at the same time, the iterable object has a function that is executed in each iterative cycle (next method call) to select a specific option value.
Manage the OptionStrategies.
Functions
OptionCollectorFactory.(options) ⇒ object
Execute normalization actions for each of the options. For example, adding default values in queries.
OptionCollectorFactory.(collector, options)
Add queries to the Collector instance to extract each of the options in the Collector run.
Collection
Execute a set of queries.
Kind: global class
.call(context) ⇒
Promise.<object>
new Collection(queries)
Param | Type | Description |
---|---|---|
queries |
| Set of queries. |
queries.* |
| QUery. |
collection.call(context) ⇒ Promise.<object>
Promise.<object>
Execute a set of queries.
Kind: instance method of Collection
Returns: Promise.<object>
- An object that represents a promise for a object with the results of the queries.
Param | Type | Description |
---|---|---|
context |
| Object that represents the context or the element that is being passed on nested queries or instances executions. |
Example
collection.postProcessor(customProcessor) ⇒ Collection
Collection
Add a new postProcessor to the list.
Kind: instance method of Collection
Returns: Collection
- Returns the current Collection instance.
Param | Type | Description |
---|---|---|
customProcessor |
| A custom functionality that receives the query result and perform a process to return a transformed data. |
IterableAccessor
Iterates over each item in context created by a collection, returning it to be collected upon.
Kind: global class
.call(context) ⇒
Promise.<Generator>
new IterableAccessor(collection)
Param | Type | Description |
---|---|---|
collection | Collection instance that provides the new context. |
iterableAccessor.call(context) ⇒ Promise.<Generator>
Promise.<Generator>
Create a generator to pass the new context.
Kind: instance method of IterableAccessor
Returns: Promise.<Generator>
- An object that represents a promise for a generator of context objects.
Param | Type | Description |
---|---|---|
context |
| Actual context object. |
Example (Receives a Collection and returns an iterable of Context objects)
ProxyAccessor
Default ContextAcessor, used when there is not contextProcessor in Collector.
Kind: global class
proxyAccessor.call(context) ⇒ Generator.<Context>
Generator.<Context>
Returns a generator with the incoming context.
Kind: instance method of ProxyAccessor
Returns: Generator.<Context>
- Returns the incoming context as part of a generator.
Param | Type | Description |
---|---|---|
context |
| Object that represents the context or the element that is being passed on nested queries or instances executions. |
Example
CollectionCollectorFactory
Create a Collector instance for collecting a collection for each iterable item in the context.
Kind: global class
new CollectionCollectorFactory(collector, queries)
Returns: Collector
- A Collector instance.
Param | Type | Description |
---|---|---|
collector |
| Collector instance. |
queries |
| Set of queries. |
ElementCollectorFactory
Creates a Collector instance that returns a NodeList of DOM elements.
Kind: global class
new ElementCollectorFactory(query)
Returns: Collector
- A new instance of Collector.
Param | Type | Description |
---|---|---|
query |
| A callabel object. |
OptionCollectorFactory
Creates a Collector instance that returns a list of combinations generated by Options intances.
Kind: global class
new OptionCollectorFactory(options)
Returns: Collector
- A Collector instance.
Param | Type | Description |
---|---|---|
options |
| A series of options. |
Option
Creates an iterable object from a series of options and at the same time, the iterable object has a function that is executed in each iterative cycle (next method call) to select a specific option value.
Kind: global class Summary: Creates an iterable object from options.
new Option(identifier, element, [strategy])
Param | Type | Description |
---|---|---|
identifier |
| This tag identifies which option certain values are linked to. For example, the CE, EE, and ECE values are tied to an Edition option. |
element |
| DOM element. |
[strategy] |
| Object that has functionalities to get options and set options. If no strategy is specified, then the Strategy Manager will assign one automatically. |
[strategy.getOptions] |
| A function that creates an array of objects, in which each one of them contains two properties: value - which refers to the value property of an element that will be used to make the selection of the option. And, the second property is the dynamic value of the label parameter, which will contain the text of the value itself. |
[strategy.setOption] |
| Function that performs a selection of an option based on a value that is specified as a parameter. |
Example (Create an Option instance of a dropwdown (select element).)
Example (Create an Option instace of a group of buttons (div elements).)
option.call()
Creates an iterable object that contains the values of an HTML element and its respective selection function. The values collection and function execution is controlled by the JavaScript Iteration Protocols.
Kind: instance method of Option
Example (Use the next generator method to get the values)
OptionStrategyManager
Manage the OptionStrategies.
Kind: global class
.lookUp(element) ⇒
Promise.<OptionStrategy>
OptionStrategyManager.add(strategy)
Add or register a OptionStrategy sub-class.
Kind: static method of OptionStrategyManager
Param | Type | Description |
---|---|---|
strategy |
| A specific implementation/sub-class of OptionStrategy. |
Example
OptionStrategyManager.lookUp(element) ⇒ Promise.<OptionStrategy>
Promise.<OptionStrategy>
Search or look up the best strategy.
Kind: static method of OptionStrategyManager
Returns: Promise.<OptionStrategy>
- Object that represents a promise to return a sub-class of OptionStrategy.
Param | Type | Description |
---|---|---|
element |
| DOM element that represents or has options. |
Example (SelectStrategy matched)
OptionCollectorFactory.(options) ⇒ object
object
Execute normalization actions for each of the options. For example, adding default values in queries.
Kind: global function
Returns: object
- The normalized options.
Param | Type | Description |
---|---|---|
options |
| Set of options. |
OptionCollectorFactory.(collector, options)
Add queries to the Collector instance to extract each of the options in the Collector run.
Kind: global function
Param | Type | Description |
---|---|---|
collector |
| Collector instance. |
options |
| Set of options. |
Classes
Creates a generator from a list of elements.
Creates a generator from a list of Option instances.
Knows how to get and set values from a group of options.
Default strategy.
Knows how to get and set values from SELECT DOM elements.
Knows how to get and set values from an element with two states: TRUE/FALSE.
Creates a query chain from a custom selector.
Manage which interpretation strategy will process the custom selector.
Contains the specific logic to process nested structures. In case no parameter is passed to its constructor then it will return the previous result in the execution of the chain.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Execute a Collector instance.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Contains specific logic to extract elements from the DOM using a CSS selector.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Returns a default value if there the expected result is not valid.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Provide a directory to store proxy function that will be used to instantiate the Implementation sub-classes. The directory is made up of the name of each proxy function and its sub-class constructor equivalent.
Creates a collector that will return a generator of a list of elements.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Perform actions during initialization.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Iterate a Collector instance against a set of queries.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Contains the specific Selector that allows concatenating other query Selectors.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Creates a collector that will return a generator of a list of option values.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Perform actions after data extraction.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Perform actions before data extraction.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Contains the specific Selector to obtain properties of DOM elements.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Returns an error if the result is not a valid value.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Interprets Select Strings.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Contains the specific Selector to check if a single element is expected as it turns out, otherwise throw an error.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Contains specific logic to extract elements from the DOM using a xpath selector.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Functions
CollectionElementProcessor.(element) ⇒ boolean
Check the object is a generator.
CollectionElementProcessor.(elements)
Create a generator from a list of elements.
CollectionOptionProcessor.(options) ⇒ Promise.<Generator>
It takes Option instances and calculates all possible values of the combinations of those options.
CollectionElementProcessor
Creates a generator from a list of elements.
Kind: global class
CollectionElementProcessor.call(elementCollection) ⇒ Generator.<(Element|any)>
Generator.<(Element|any)>
Execute the processor.
Kind: static method of CollectionElementProcessor
Returns: Generator.<(Element|any)>
- A generator with DOM elements.
Param | Type | Description |
---|---|---|
elementCollection |
| A serie of DOM elements or generator. |
Example (Receives a collection with a list of DOM elements an returns an array with elements)
CollectionOptionProcessor
Creates a generator from a list of Option instances.
Kind: global class
CollectionOptionProcessor.call(elementCollection) ⇒ Promise.<Generator>
Promise.<Generator>
Returns all possible values of the options that were passed to Collection.
Kind: static method of CollectionOptionProcessor
Returns: Promise.<Generator>
- An object that represents a promise object for a generator containing all the possible values processed of each option.
Param | Type | Description |
---|---|---|
elementCollection |
| A serie of elements or Options instances. |
Example (Processing a series of options)
GroupStrategy
Knows how to get and set values from a group of options.
Kind: global class
.getOptions(identifier, element) ⇒
Promise.<Array>
.setOption(element, value) ⇒
Promise.<Boolean>
.match(element) ⇒
Promise.<Boolean>
GroupStrategy.getOptions(identifier, element) ⇒ Promise.<Array>
Promise.<Array>
Extract a value that will be used to identify each option.
Kind: static method of GroupStrategy
Returns: Promise.<Array>
- Object that represents a promise for a list of objects.
Param | Type | Description |
---|---|---|
identifier |
| Identifies the option values referenced by the element in the DOM. |
element |
| DOM element that contains one or more values. |
Example (Get options from a select element)
GroupStrategy.setOption(element, value) ⇒ Promise.<Boolean>
Promise.<Boolean>
Select a specific option.
Kind: static method of GroupStrategy
Returns: Promise.<Boolean>
- Object that represents a promise for the completion of a select action.
Param | Type | Description |
---|---|---|
element |
| DOM element that contains one or more values. |
value |
| Value that will be used to select a specific option. |
Example (Set second option to a div element)
GroupStrategy.match(element) ⇒ Promise.<Boolean>
Promise.<Boolean>
Check if the particular strategy is suitable for a certain element of the DOM.
Kind: static method of GroupStrategy
Returns: Promise.<Boolean>
- Object that represents a promise for a TRUE or FALSE value.
Param | Type | Description |
---|---|---|
element |
| DOM element that contains one or more values. |
Example (Match elements)
MissingStrategy
Default strategy.
Kind: global class
SelectStrategy
Knows how to get and set values from SELECT DOM elements.
Kind: global class
.getOptions(identifier, element) ⇒
Promise.<Array>
.setOption(element, value) ⇒
Promise.<void>
.match(element) ⇒
Promise.<(Boolean|Error)>
SelectStrategy.getOptions(identifier, element) ⇒ Promise.<Array>
Promise.<Array>
Extract a value that will be used to identify each option.
Kind: static method of SelectStrategy
Returns: Promise.<Array>
- Object that represents a promise for a list of objects.
Param | Type | Description |
---|---|---|
identifier |
| Identifies the option values referenced by the element in the DOM. |
element |
| DOM element that contains one or more values. |
Example (Get options from a select element)
SelectStrategy.setOption(element, value) ⇒ Promise.<void>
Promise.<void>
Select a specific option.
Kind: static method of SelectStrategy
Returns: Promise.<void>
- Object that represents a promise for the completion of a select action.
Param | Type | Description |
---|---|---|
element |
| DOM element that contains one or more values. |
value |
| Value that will be used to select a specific option. |
Example (Set second option to a select element)
SelectStrategy.match(element) ⇒ Promise.<(Boolean|Error)>
Promise.<(Boolean|Error)>
Check if the particular strategy is suitable for a certain element of the DOM.
Kind: static method of SelectStrategy
Returns: Promise.<(Boolean|Error)>
- Object that represents a promise for a TRUE or FALSE value.
Param | Type | Description |
---|---|---|
element |
| DOM element that contains one or more values. |
Example (Match a SELECT element)
ToogleStrategy
Knows how to get and set values from an element with two states: TRUE/FALSE.
Kind: global class
.getOptions(identifier, element) ⇒
Promise.<Array>
.setOption(element, value) ⇒
Promise.<void>
.match(element) ⇒
Promise.<(Boolean|Error)>
ToogleStrategy.getOptions(identifier, element) ⇒ Promise.<Array>
Promise.<Array>
Extracts a value that will be used to identify each option.
Kind: static method of ToogleStrategy
Returns: Promise.<Array>
- Object that represents a promise for a list of objects.
Param | Type | Description |
---|---|---|
identifier |
| Identifies the option values referenced by the element in the DOM. |
element |
| DOM element that contains one or more values. |
Example (Get options from a checkbox element)
ToogleStrategy.setOption(element, value) ⇒ Promise.<void>
Promise.<void>
Select a specific option.
Kind: static method of ToogleStrategy
Returns: Promise.<void>
- Object that represents a promise for the completion of a select action.
Param | Type | Description |
---|---|---|
element |
| DOM element that contains one or more values. |
value |
| Value that will be used to select a specific option. |
Example (Select an input element)
ToogleStrategy.match(element) ⇒ Promise.<(Boolean|Error)>
Promise.<(Boolean|Error)>
Check if the particular strategy is suitable for a certain element of the DOM.
Kind: static method of ToogleStrategy
Returns: Promise.<(Boolean|Error)>
- Object that represents a promise for a TRUE or FALSE value.
Param | Type | Description |
---|---|---|
element |
| DOM element that contains one or more values. |
Example (Match an element)
SelectorInterpreter
Creates a query chain from a custom selector.
Kind: global class
new SelectorInterpreter(selector)
Returns: Query
- A query instance.
Param | Type | Description |
---|---|---|
selector |
| A custom selector. |
Example
InterpreterStrategyManager
Manage which interpretation strategy will process the custom selector.
Kind: global class
InterpreterStrategyManager.add(strategy)
Add a new strategy.
Kind: static method of InterpreterStrategyManager
Param | Type | Description |
---|---|---|
strategy |
| A strategy that can process a custom selector. |
Example
InterpreterStrategyManager.lookUp(selector) ⇒ object
object
Search among the available strategies which of them is the most suitable to process a specific selector.
Kind: static method of InterpreterStrategyManager
Returns: object
- A strategy that can process the custom selector.
Param | Type | Description |
---|---|---|
selector |
| Custom selector. |
Example ({h1} gets InterpreterElementStrategy)
All
Contains the specific logic to process nested structures. In case no parameter is passed to its constructor then it will return the previous result in the execution of the chain.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class Summary: Process nested structures.
CollectorSelector
Execute a Collector instance.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Css
Contains specific logic to extract elements from the DOM using a CSS selector.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class Summary: Extracts Dom Elements.
Default
Returns a default value if there the expected result is not valid.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
SelectorDirectory
Provide a directory to store proxy function that will be used to instantiate the Implementation sub-classes. The directory is made up of the name of each proxy function and its sub-class constructor equivalent.
Kind: global class Summary: Keep a record of Selector subclasses.
SelectorDirectory.register(selector)
Saves a record of the subclass within the registry as a function.
Kind: static method of SelectorDirectory
Param | Type | Description |
---|---|---|
selector |
| Constructor class such as Css, Property, Single, etc. |
Example (Use in Selector class)
SelectorDirectory.get(name) ⇒ function
function
Returns the proxy function that was previously registered within the registry object.
Kind: static method of SelectorDirectory
Returns: function
- Proxy function that will create the instance of the sub-class.
Param | Type | Description |
---|---|---|
name |
| Name of the function stored in the registry object. It will be the lowercase version of the sub-class name. |
Example (Use in Selector class)
SelectorDirectory.iterate()
Creates an iterable object of all registries inside the registry object.
Kind: static method of SelectorDirectory
Elements
Creates a collector that will return a generator of a list of elements.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Init
Perform actions during initialization.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Init.register()
Modifies the registry process in SelectorDirectory class.
Kind: static method of Init
Iterate
Iterate a Collector instance against a set of queries.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Merge
Contains the specific Selector that allows concatenating other query Selectors.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class Summary: Concatenates query Selectors
Options
Creates a collector that will return a generator of a list of option values.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Post
Perform actions after data extraction.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Pre
Perform actions before data extraction.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Property
Contains the specific Selector to obtain properties of DOM elements.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class Summary: Obtain properties.
Require
Returns an error if the result is not a valid value.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Select
Interprets Select Strings.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Single
Contains the specific Selector to check if a single element is expected as it turns out, otherwise throw an error.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class Summary: Check for a single result of the previous Selector.
Xpath ⇐ Selector
Selector
Contains specific logic to extract elements from the DOM using a xpath selector.
The class itself is not open to developer use, but rather is used by a proxy function to build the instance. See the example for more information.
Kind: global class
Summary: Extracts Dom Elements.
Extends: Selector