Skip to content

Latest commit

 

History

History
1374 lines (1010 loc) · 57.3 KB

api.md

File metadata and controls

1374 lines (1010 loc) · 57.3 KB

Classes

Controller

Class to connect identity with custom functions (Class Functions) in order to avoid code repetitions

Identity

Used Identity for automation

SearchQueryEvaluators

Class which includes example evaluators which can be used with getQuery

SearchQueries

Includes functions which return generated search queries. Uses SearchQueryGenerator.

SearchQueryGenerator

Class for the generic search query generator

Functions

Custom functions which enhance the Puppeteer standard functionality

Controller

Class to connect identity with custom functions (Class Functions) in order to avoid code repetitions

Kind: global class

new Controller(identity, endpoint)

constructor

Param Type Default Description
identity Identity Identity to use
endpoint String WebSocket-Endpoint

controller.typeSearchQuery(selector, generatorName) ⇒ void

Types a search query generated by the given search query generator inside the target input element inside the current tab with randomized typing delays defined by the identity

Kind: instance method of Controller

Param Type Default Description
selector string Selector ot the target input element. If the selector is not given, the typing events will be executed without focusing the input element.
generatorName string ""default"" Name of the search query generator defined in the settings which should be used. Default values can be found inside include/settings.js

controller.getRandomTime(time, random) ⇒ number

Return random time

Kind: instance method of Controller
Returns: number - Random number inside range [time +/- random]

Param Type Description
time number Average time in milliseconds
random number Maximum deviation from average time in milliseconds

controller.getRandomNumber(to, from) ⇒ number

Return random number with seedrandom library

Kind: instance method of Controller
Returns: number - Random number inside range [from-to]

Param Type Default Description
to number To
from number 0 From

controller.getRandomBoolean(truePercent) ⇒ Boolean

Return random boolean value

Kind: instance method of Controller

Param Type Default Description
truePercent Number 0.5 Probability for returning true (comma value between 0 and 1)

controller.getPage() ⇒ page

getPage - Returns current page tab

Kind: instance method of Controller
Returns: page - Page-Object

controller.getIdentity() ⇒ Identity

Returns the identity used in this controller

Kind: instance method of Controller
Returns: Identity - Identity

controller.init(executablePath) ⇒ void

Initiate browser and open new tab. The tab is focused.

Kind: instance method of Controller
Category: async

Param Type Default Description
executablePath string """" Path to a Chromium or Chrome executable to run instead of the standard Chromium included in Puppeteer. Normal bundled version will be started, if not set.

controller.focusPage(url) ⇒ boolean

Searches Tab with given URL and focuses this tab. The old Tab will stay focused if no Tab with the URL has been matched.

Kind: instance method of Controller
Returns: boolean - True: Tab found, False: Tab not found
Category: async

Param Type Description
url String Beginning of URL of targeted Page tab

controller.newPage(url) ⇒ void

Opens new Page tab and opens the given url inside the tab. The new tab is focused afterwards.

Kind: instance method of Controller
Category: async

Param Type Default Description
url string """" URL to be loaded. No page will be loaded if the string is empty.

controller.closePage(url) ⇒ void

Closes page with given URL. Current open Tab is closed, if no URL is given. The last known open Tab will selected after closing.

Kind: instance method of Controller
Category: async

Param Type Default Description
url String "" Beginning of URL of targeted Tab

controller.focusFrame(url) ⇒ boolean

Searches for inline frame with given URL start in the current tab and focuses it for following events (typeFrame or clickFrame)

Kind: instance method of Controller
Returns: boolean - True: Frame has been found, False: Frame has not been found
Category: async

Param Type Description
url String Beginning of URL of targeted iFrame inside the current page tab

controller.type(selector, text) ⇒ void

Types inside the target input element inside the current tab with randomized typing delays defined by the identity

Kind: instance method of Controller
Category: async

Param Type Description
selector string Selector ot the target input element. If the selector is not given, the typing events will be executed without focusing the input element.
text string Text which should be entered

controller.typeFrame(selector, text) ⇒ void

Types inside the target input element inside the current selected frame with randomized typing delays defined by the identity

Kind: instance method of Controller
Category: async

Param Type Description
selector string Selector ot the target input element. If the selector is not given, the typing events will be executed without focusing the input element.
text string Text which should be entered

controller.typeEnter() ⇒ void

Presses Enter button on current tab with random press and release time

Kind: instance method of Controller
Category: async

controller.typeTab() ⇒ void

Presses Tab button on current tab

Kind: instance method of Controller
Category: async

controller.typeEsc() ⇒ type

Presses ESC button

Kind: instance method of Controller
Category: async

controller.click(selector, delay, tap, topRight, doTrigger) ⇒ void

Click on target element with random deviation around the click position and error handling. Every click is saved as a screenshot.

Kind: instance method of Controller
Category: async

Param Type Default Description
selector string Selector of target element
delay number true Random delay between MouseDown und MouseUp event
tap Boolean false Send touchscreen tap instead of MouseClick event
topRight Boolean false Click inside of the top right corner instead of the element's center.
doTrigger Boolean false Manually trigger the click event via JavaScript if error occurred (can happen, if Dropdown menu closed before the click has been executed)

controller.clickFrame(selector) ⇒ void

Click on target element of selected frame with error handling. Version for iFrame.

Kind: instance method of Controller
Category: async

Param Type Description
selector string Selector of target element

controller.hover(page, selector) ⇒ void

Hover over targeted element

Kind: instance method of Controller
Category: async

Param Type Description
page Page Page object
selector string Selector of target element

controller.waitForSelector(selector, doThrow) ⇒ void

Wait for visibility of selector on current tab with error error handling

Kind: instance method of Controller
Category: async

Param Type Default Description
selector string Selector of target element
doThrow boolean false throws an error instead of invoking the internal errorHandling function

controller.select(selector, value) ⇒ void

Selects value of dropdown list inside the current tab with error handling.

Kind: instance method of Controller
Category: async

Param Type Description
selector string Selector of target element
value string Selection value of target value (value="VALUE")

controller.selectFrame(selector, value) ⇒ void

Selects value of dropdown list inside the selected frame with error handling.

Kind: instance method of Controller
Category: async

Param Type Description
selector string Selector of target element
value string Selection value of target value (value="VALUE")

controller.goto(url) ⇒ void

Opens URL in current tab

Kind: instance method of Controller
Category: async

Param Type Description
url string URL

controller.randomWait(time, random) ⇒ void

Waits for random time range

Kind: instance method of Controller
Category: async

Param Type Default Description
time number 2000 Average waiting time in milliseconds
random number 1000 Maximum deviation from average waiting time in milliseconds

controller.waitForNavigation() ⇒ void

async waitForNavigation - description

Kind: instance method of Controller
Returns: void - description
Category: async

controller.logScreenshot(page, text) ⇒ void

Create screenshot of page and save it inside the log

Kind: instance method of Controller
Category: async

Param Type Description
page Object Element from which the screenshot should be taken from [Page, Element, Frame]
text string Text for the log entry

controller.isSelectorVisible(selector) ⇒ Boolean

Check if selector is visible on page

Kind: instance method of Controller
Returns: Boolean - true: visible, false: not visible
Category: async

Param Type Description
selector String Selector of target

controller.scrollToSelector(stopSelector, wait) ⇒ void

Scrolls to given selector

Kind: instance method of Controller
Category: async

Param Type Default Description
stopSelector String Selector to which the function should scroll
wait Boolean true Wait after half of page is scrolled

controller.scrollToBottom() ⇒ type

async scrollToBottom - Scrolls to Bottom of current page (last div-Element).

Kind: instance method of Controller
Returns: type - description
Category: async

controller.scrollUp(stopSelector, wait, press, minScrolls, maxScrolls) ⇒ void

Scrolls page up until the selector is visible

Kind: instance method of Controller
Category: async

Param Type Default Description
stopSelector string Selector to which the function should scroll up
wait boolean true Wait after half of page is scrolled
press boolean false true: Scrolling is achieved with long button press of page down-button, false: Scrolling is achieved with several short arrow down button presses
minScrolls number 11 Minimum number of keyboard presses for scrolling (if press=false)
maxScrolls number 15 Maximum number of keyboard presses for scrolling (if press=false)

controller.scrollDown(stopSelector, wait, press, minScrolls, maxScrolls, minIterations) ⇒ void

Scrolls page down until the selector is visible

Kind: instance method of Controller
Category: async

Param Type Default Description
stopSelector string Selector to which the function should scroll up
wait boolean true Wait after half of page is scrolled
press boolean false true: Scrolling is achieved with long button press of page down-button, false: Scrolling is achieved with several short arrow down button presses
minScrolls number 11 Minimum number of keyboard presses for scrolling (if press=false)
maxScrolls number 15 Maximum number of keyboard presses for scrolling (if press=false)
minIterations number 0 Minimum number of how many iterations this scrolling have to be repeated (even if element has already been scrolled by)

controller.setValue(selector, text) ⇒ void

Change HTML-DOM value (z.B. Textarea elements)

Kind: instance method of Controller
Category: async

Param Type Description
selector string Selektor of target
text Sting Value text to which the selected element should be changed

controller.deactivateLink(selector) ⇒ void

Deactivate link invocation behavior inside the browser page with injection of JavaScript

Kind: instance method of Controller
Category: async

Param Type Description
selector string Target selector of link which should be deactivated

controller.getHref(selector) ⇒ string

Get Href (link) content of targeted DOM element

Kind: instance method of Controller
Returns: string - Href content
Category: async

Param Type Description
selector string Selector of target

controller.goBack() ⇒ void

async goBack - Open prior page in browser history of current tab

Kind: instance method of Controller
Category: async

controller.solveCaptcha(selector) ⇒ string

Solve image captcha inside the page with the help of the Anti-Captcha service. Needs anti-captcha library to work. Library can be downloaded at https://github.com/AdminAnticaptcha/anticaptcha-nodejs/blob/master/anticaptcha.js and the file has to be put into the "lib"-folder of this project.

Kind: instance method of Controller
Returns: string - Submitted solution of the Captcha
Category: async

Param Type Description
selector string Selector of the Captcha

controller.solveRecaptcha(selector) ⇒ string

Solve reCAPTCHA inside iFrame with the help of the Anti-Captcha service Needs anti-captcha library to work. Library can be downloaded at https://github.com/AdminAnticaptcha/anticaptcha-nodejs/blob/master/anticaptcha.js and the file has to be put into the "lib"-folder of this project.

Kind: instance method of Controller
Returns: string - reCAPTCHA solution string which has to be injected into hidden textarea element before submission of the form.
Category: async

Param Type Description
selector string Selector to the reCAPTCHA iframe included inside the given frame element (needs to have URL to reCAPTCHA inside the HTML DOM attribute "src").

Identity

Used Identity for automation

Kind: global class

new Identity(firstname, lastname, birthday, email, password, company, position, typespeed, random, gender)

Constructor

Param Type Default Description
firstname string First name
lastname string Last name
birthday Date Birthday
email string Email address
password string password
company string Conpany
position string ""Employee"" Position in company
typespeed number 456 Average typing speed
random number 265 Random deviation from average typing speed
gender number global.GENDER_MALE Gender

identity.isMale() ⇒ boolean

Returns if identity is of male gender

Kind: instance method of Identity

identity.getBirthdayString() ⇒ String

Returns a formatted String of the Identity-Birthday

Kind: instance method of Identity
Returns: String - Birthday as a String

SearchQueryEvaluators

Class which includes example evaluators which can be used with getQuery

Kind: global class

SearchQueryEvaluators.evaluateNormal(item) ⇒ String

Evaluation function for a normal RSS feed: Takes the item -> title object of the feed and returns it in lowercase

Kind: static method of SearchQueryEvaluators
Returns: String - Lowercase string of item title

Param Type Description
item Item Single item of parsed feed

SearchQueryEvaluators.evaluateSPON(item) ⇒ String

Evaluation function for the use case of Spiegel Online headlines

Kind: static method of SearchQueryEvaluators
Returns: String - Generated search query out of the single item

Param Type Description
item Item Single item of parsed feed

SearchQueries

Includes functions which return generated search queries. Uses SearchQueryGenerator.

Kind: global class

SearchQueries.getRandomQuery() ⇒ String

Returns search query generated of the spiegelonline evaluator (see SearchQueryEvaluators for details)

Kind: static method of SearchQueries
Returns: String - Search query

SearchQueries.getFacebookQuery() ⇒ String

Returns search query generated of the facebook evaluator (see searchQueryEvaluators for details)

Kind: static method of SearchQueries
Returns: String - Search query

SearchQueries.getQuery(generatorName) ⇒ String

Returns search query generated of the a given search query evaluator (see searchQueryEvaluators for details)

Kind: static method of SearchQueries
Returns: String - Search query randomly selected of returned array of the called search query generator

Param Type Description
generatorName String Name of the search query generator defined inside the Framework Settings (for default values see include/settings.js). The function SearchQueryGenerator.getQueries is called with the parameters defined in the settings.

SearchQueryGenerator

Class for the generic search query generator

Kind: global class

SearchQueryGenerator.getQueries(rssFeedURL, cacheFileName, queryArrayObject, evaluationFunction) ⇒ Array

Fetch RSS and generate an array containing generated search queries out of the feed with its evaluationFunction.

Kind: static method of SearchQueryGenerator
Returns: Array - Array with generated search queries

Param Type Default Description
rssFeedURL String URL of RSS feed which should be parsed
cacheFileName String File name of the cache file which is generated inside the tmp-folder of the project
queryArrayObject Object Array object which should contain the contents of the generated array. The contents will be written to this object.
evaluationFunction function evaluateNormal Function which should evaluate every single item of the RSS feed. The function has to return a string of the generated search query out of the item. Function has to be: Function(item) -> string

Functions

Custom functions which enhance the Puppeteer standard functionality

Kind: global class

Functions.getRandomTime(time, random) ⇒ number

Return random time

Kind: static method of Functions
Returns: number - Random number inside range [time +/- random]

Param Type Description
time number Average time in milliseconds
random number Maximum deviation from average time in milliseconds

Functions.getRandomNumber(to, from) ⇒ number

Return random number with seedrandom library

Kind: static method of Functions
Returns: number - Random number inside range [from-to]

Param Type Default Description
to number To
from number 0 From

Functions.getRandomBoolean(truePercent) ⇒ Boolean

Return random boolean value

Kind: static method of Functions

Param Type Default Description
truePercent Number 0.5 Probability for returning true (comma value between 0 and 1)

Functions.getPage(browser, url) ⇒ Page

Searches tab with given url and returns this tab

Kind: static method of Functions
Returns: Page - Seite
Category: static async

Param Type Description
browser Browser Browser element
url string Beginning of URL of targeted Tab

Functions.closePage(browser, url) ⇒ void

Searches tab with given URL and closes this tab

Kind: static method of Functions
Category: static async

Param Type Description
browser Browser Browser-Element
url string Beginning of URL of targeted Page tab

Functions.newPage(browser, url) ⇒ Page

Opens new Page tab and opens the given url inside the tab. The new tab is focused afterwards.

Kind: static method of Functions
Returns: Page - The new Page tab
Category: static async

Param Type Default Description
browser Browser Browser object
url string """" URL to be loaded. No page will be loaded if the string is empty.

Functions._enableCamouflage(page) ⇒ void

Enables additional protection mechanisms for the given page to reduce possibilities for services to identify the headless browser

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page object for which the mechanisms should be enabled

Functions.getFrame(page, url) ⇒ Frame

Searches for inline frame with given URL start and returns the frame

Kind: static method of Functions
Returns: Frame - Frame element
Category: static async

Param Type Description
page Page Page element
url string Beginning of URL of targeted iFrame inside the current page tab

Functions.bringToFront(page) ⇒ void

Brings page to front (activates page tab)

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page-Object

Functions.init(puppeteer, endpoint, executablePath) ⇒ Object

Initialize Browser session or connects to active browser session and opens new tab. Browser will be started in normal mode instead of the headless mode.

Kind: static method of Functions
Returns: Object - Initialisiierungselemente [Page, Browser]
Category: static async

Param Type Default Description
puppeteer Puppeteer Puppeteer element
endpoint string Websocket-Endpoint. Browser session will be initialized, if not set.
executablePath string """" Path to a Chromium or Chrome executable to run instead of the standard Chromium included in Puppeteer. Normal bundled version will be started, if not set.

Functions.getBottomSelector(page) ⇒ string

Get selector of last visible Div-element on the page

Kind: static method of Functions
Returns: string - Bottom selector
Category: static async

Param Type Description
page Page Page object

Functions.getHref(page, selector) ⇒ string

Get Href (link) content of targeted DOM element

Kind: static method of Functions
Returns: string - Href content
Category: static async

Param Type Description
page Page page object
selector string Selector of target

Functions.hover(page, selector) ⇒ void

Hover over targeted element

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page object
selector string Selector of target element

Functions.click(page, selector, delay, tap, topRight, doTrigger) ⇒ void

Click on target element with random deviation around the click position and error handling. Every click is saved as a screenshot.

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page element
selector string Selector of target element
delay number true Random delay between MouseDown und MouseUp event
tap Boolean false Send touchscreen tap instead of MouseClick event
topRight Boolean false Click inside of the top right corner instead of the element's center.
doTrigger Boolean false Manually trigger the click event via JavaScript if error occurred (can happen, if Dropdown menu closed before the click has been executed)

Functions.clickFrame(frame, selector) ⇒ void

Click on target element with error handling. Version for iFrame.

Kind: static method of Functions
Category: static async

Param Type Description
frame Frame Frame element
selector string Selector of target element

Functions.exit() ⇒ void

Exit program without error

Kind: static method of Functions
Category: static async

Functions.waitForSelector(page, selector, doThrow) ⇒ void

Wait for visibility of selector with error error handling

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page element
selector string Selector of target element
doThrow boolean false throws an error instead of invoking the internal errorHandling function

Functions.select(page, selector, value) ⇒ void

Selects value of dropdown list with error handling

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page element
selector string Selector of target element
value string Selection value of target value (value="VALUE")

Functions.selectFrame(frame, selector, value) ⇒ void

Selects value of dropdown list with error handling Version for iFrames

Kind: static method of Functions
Category: static async

Param Type Description
frame Frame Frame element
selector string Selector of target element
value string Selection value of target value (value="VALUE")

Functions.type(page, selector, text, time, random) ⇒ void

Types inside the target input element with randomized typing delays

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page element
selector string Selector ot the target input element. If the selector is not given, the typing events will be executed without focusing the input element.
text string Text which should be entered
time number 456 Average typing delay in milliseconds
random number 265 Random deviation from average typing delay in milliseconds

Functions.typeFrame(Frame, selector, text, time, random) ⇒ void

Types inside the target input element with randomized typing delays Version for iFrames

Kind: static method of Functions
Category: static async

Param Type Default Description
Frame Frame Frame element
selector string Selector ot the target input element. If the selector is not given, the typing events will be executed without focusing the input element.
text string Text which should be entered
time number 456 Average typing delay in milliseconds
random number 265 Random deviation from average typing delay

Functions.typeEnter(page) ⇒ void

Presses Enter button with random press and release time

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page element

Functions.typeTab(page) ⇒ void

Presses Tab button

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page element

Functions.typeEsc(page) ⇒ type

Presses ESC button

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page element

Functions.typeUp(page, pageUp) ⇒ void

Presses ArrowUp or PageUp button with random delay

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page element
pageUp boolean false Presses PageUp button

Functions.typeDown(page, pageDown) ⇒ void

Presses ArrowDown or PageDown button with random delay

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page element
pageDown boolean false Presses PageDown button

Functions.scrollToSelector(page, stopSelector, wait) ⇒ void

Scrolls to given selector

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page object
stopSelector string Selector to which the function should scroll
wait boolean true Wait after half of page is scrolled

Functions.scrollUp(page, stopSelector, wait, press, minScrolls, maxScrolls) ⇒ void

Scrolls page up until the selector is visible

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page object
stopSelector string Selector to which the function should scroll up
wait boolean true Wait after half of page is scrolled
press boolean false true: Scrolling is achieved with long button press of page up-button, false: Scrolling is achieved with several short arrow up button presses
minScrolls number 11 Minimum number of keyboard presses for scrolling (if press=false)
maxScrolls number 15 Maximum number of keyboard presses for scrolling (if press=false)

Functions.scrollDown(page, stopSelector, wait, press, minScrolls, maxScrolls, minIterations) ⇒ void

Scrolls page down until the selector is visible

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page object
stopSelector string Selector to which the function should scroll up
wait boolean true Wait after half of page is scrolled
press boolean false true: Scrolling is achieved with long button press of page down-button, false: Scrolling is achieved with several short arrow down button presses
minScrolls number 11 Minimum number of keyboard presses for scrolling (if press=false)
maxScrolls number 15 Maximum number of keyboard presses for scrolling (if press=false)
minIterations number 0 Minimum number of how many iterations this scrolling have to be repeated (even if element has already been scrolled by)

Functions.setValue(page, selector, text) ⇒ void

Change HTML-DOM value (z.B. Textarea elements)

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page or frame element
selector string Selektor of target
text Sting Value text to which the selected element should be changed

Functions.deactivateLink(page, selector) ⇒ void

Deactivate link invocation behavior inside the browser page with injection of JavaScript

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page-Element
selector string Target selector of link which should be deactivated

Functions.triggerClick(page, selector) ⇒ void

Trigger click event manually via JavaScript code injection (element does not have to be visible inside the browser)

Kind: static method of Functions
Category: static async

Param Type Description
page Page Page element
selector string Target selector to the (link/button) element which should be triggered by the function

Functions.randomWait(page, time, random) ⇒ void

Waits for random time range

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page element
time number 2000 Average waiting time in milliseconds
random number 1000 Maximum deviation from average waiting time in milliseconds

Functions.randomTimeout(time, random) ⇒ void

Waits for a random time (alternate implementation to the randomWait function without page element)

Kind: static method of Functions
Category: static async

Param Type Default Description
time number 2000 Average waiting time in milliseconds
random number 1000 Maximum deviation from average waiting time

Functions.controlStatus(browser, page, searchURL, timeout) ⇒ void

Bring page tab to the front every time after the timeout. Function is used for several services which are known for opening extra tabs which might crash functionality in the "headfull" mode (since the tab is not focused anymore).

You need to set global.controlStatusRunning=true before starting this function in order to work. Function will stop when controlStatusRunning is set to false.

WARNING: Never use this function with "await" since it will never stop.

Kind: static method of Functions
Category: static async

Param Type Default Description
browser Browser Browser element
page Page Page element
searchURL string URL to search for the defined tab
timeout number 60000 Timeout in milliseconds

Functions.errorHandling(page, e, doScreenshot) ⇒ type

Error handling function: Creates screenshot, creates log entry with it and exits the program

Kind: static method of Functions
Category: static async

Param Type Default Description
page Page Page element
e Error Error element
doScreenshot type true Create screenshot of page

Functions.getScreenshot(page, fullPage) ⇒ String

Creates screenshot and returns it as a Base64 encoded string

Kind: static method of Functions
Returns: String - Base64-encoded string of screenshot
Category: static async

Param Type Default Description
page Page Page object
fullPage boolean false Create screenshot of full page

Functions.logScreenshot(page, text) ⇒ void

Create screenshot and save it inside the log

Kind: static method of Functions
Category: static async

Param Type Description
page Object Element from which the screenshot should be taken from [Page, Element, Frame]
text string Text for the log entry

Functions.isSelectorVisible(page, selector) ⇒ Boolean

Check if selector is visible on page

Kind: static method of Functions
Returns: Boolean - true: visible, false: not visible
Category: static async

Param Type Description
page Page Page-Element
selector string Selector of target

Functions.isInViewport(page, selector, scrollDown) ⇒ Boolean

Check if selector is visible inside the browser window or has been overscrolled before.

Kind: static method of Functions
Returns: Boolean - true: visible, false: not visible
Category: static async

Param Type Default Description
page Page Page element
selector string Target selector
scrollDown Boolean true Scrolling direction (true: downwards, false: upwards)

Functions.getScrollY(page, selector) ⇒ number

Get horizontal scroll variable

Kind: static method of Functions
Returns: number - Y-scroll position
Category: static async

Param Type Description
page Page Page object
selector string Selector of target

Functions.debugLog(key, value, imageData) ⇒ void

Creates debug output in console and writes the log entry into the database. The constant DEBUG inside settings.js has to be set to true to see the log entries. The object global.logger of type Logger (class/logger.js) has to be defined and initialized to enable database logging. Log entries will be created in the Database if the value is set.

Kind: static method of Functions
Category: static async

Param Type Default Description
key string Text which should be outputted
value type "" Second text which should be outputted. If this values is unequal to "", the log entry will be logged into the database.
imageData type "" Base64 encoded imagedata

Functions.solveCaptcha(page, selector) ⇒ string

Solve image captcha with the help of the Anti-Captcha service. Needs anti-captcha library to work. Library can be downloaded at https://github.com/AdminAnticaptcha/anticaptcha-nodejs/blob/master/anticaptcha.js and the file has to be put into the "lib"-folder of this project.

Kind: static method of Functions
Returns: string - Submitted solution of the Captcha
Category: static async

Param Type Description
page Page Page element
selector string Selector of the Captcha

Functions.solveRecaptcha(iframe, selector) ⇒ string

Solve reCAPTCHA with the help of the Anti-Captcha service. Needs anti-captcha library to work. Library can be downloaded at https://github.com/AdminAnticaptcha/anticaptcha-nodejs/blob/master/anticaptcha.js and the file has to be put into the "lib"-folder of this project.

Kind: static method of Functions
Returns: string - reCAPTCHA solution string which has to be injected into hidden textarea element before submission of the form.
Category: static async

Param Type Description
iframe Frame Frame element (page element could be possible, but not tested)
selector string Selector to the reCAPTCHA iframe included inside the given frame element (needs to have URL to reCAPTCHA inside the HTML DOM attribute "src").