Function
Static Public Summary | ||
public |
addBehaviorStyle(styleDef: string): Object Creates a style tag if one was not created before and adds
the supplied |
|
public |
addClass(elem: SomeElement, clazz: string) Adds a CSS classname to the supplied element |
|
public |
addOutLinks(toAdd: Array<HTMLAnchorElement|HTMLAreaElement>|NodeList<HTMLAnchorElement|HTMLAreaElement>) Add the array/nodelist of A or Anchor tags href properties the collected outlinks |
|
public |
addOutlink(elemOrString: HTMLAnchorElement | HTMLAreaElement | string) Add the URL or href value of the supplied argument |
|
public |
anySelectorExists(selectors: Array<string>, cntx: SomeElement): {idx: number, success: boolean} Determines if the element the supplied selector selects exists. |
|
public |
attr(elem: SomeElement, attr: string): * Retrieves the value of an elements attribute if it exists |
|
public |
attrEq(elem: SomeElement, attr: string, shouldEq: *): boolean Tests to determine if the value of elements attribute equals the supplied value using loose equality |
|
public |
Initiates an pywb/webrecorder auto-fetch of content |
|
public |
autobind(clazz: *) Automatically binds the non-inherited functions of the supplied class to itself. |
|
public |
Navigate the browser back 1 entry in the history stack. |
|
public |
Returns the value |
|
public |
buildCustomPostStepFn(customFN: function(rawResults: RawBehaviorStepResults): void): function(state: RawBehaviorStepResults): BehaviorStepResults Creates and returns a function wrapping the provided post step function will call the supplied function and return the expected output. |
|
public |
Attempts to convert the supplied string into camel case |
|
public |
camelCaseToDashDelim(str: string): string Attempts to convert the supplied camel case string into dash delimited string |
|
public |
Attempts to convert the supplied camel case string into an underscore delimited string |
|
public |
canAccessIf(iframe: HTMLIFrameElement): boolean Determines if the supplied iframe is accessible from this origin. |
|
public |
Determines if we can scroll down any more |
|
public |
Determines if we can scroll up any more |
|
public |
capitalize(str: string): string Attempts to capitalize the supplied string |
|
public |
chainFistChildElemOf(elem: SomeElement, times: number): SomeElement Chains firstChildElementOf on the supplied element n |
|
public |
chainLastChildElemOf(elem: SomeElement, times: number): SomeElement Chains lastChildElementOf n |
|
public |
chainNthChildElementOf(elem: SomeElement, nths: ...number): SomeElement Chains nthChildElementOf for each nth child element in |
|
public |
chainNthChildNodeOf(startingElem: SomeElement, nths: ...number): SomeElement Chains nthChildElemOf for each nth child in |
|
public |
chainQs(startingSelectFrom: SomeElement | Document, startingSelector: string, selectors: ...string): SomeElement Consecutively calls querySelector(selector) on the element returned by the previous invocation |
|
public |
* childElementIterator(parentElement: SomeElement): IterableIterator<SomeElement> Returns an iterator over the supplied parent element's child elements that ends once the current child has no next element sibling. If the parent element is null/undefined then the returned iterator yields nothing. |
|
public |
* childNodeIterator(parentElement: SomeElement): IterableIterator<Node> Returns an iterator over the supplied parent element's child nodes that ends once the current child has no next sibling. If the parent element is null/undefined then the returned iterator yields nothing. |
|
public |
click(elem: SomeElement): boolean Calls the click function on the supplied element if non-null/defined. |
|
public |
async clickAndWaitFor(elem: Element | Node | HTMLElement, predicate: function(): boolean, options: WaitForOptions): Promise<{predicate: boolean, maxExceeded: boolean, clicked: boolean}>{predicate:> Clicks the supplied element and then waits for the supplied predicate function to return true |
|
public |
async clickAndWaitForHistoryChange(elemToBeClicked: Element | HTMLElement, waitOpts: WaitForOptions): Promise<{oldlocation: ?string, historyChanged: boolean, clicked: boolean, newLocation: ?string, ok: boolean}>{oldlocation:> Clicks the supplied element and waits for browser history to change (the URL is updated by JavaScript modifying the current history stack) |
|
public |
clickInContext(elem: SomeElement, cntx: Window): boolean Calls the click function on the supplied element if non-null/defined that exists in the JS context of the supplied window (cntx). |
|
public |
async clickInContextWithDelay(elem: HTMLElement | Element, cntx: Window, delayTime: number): Promise<boolean> Calls the click method of the supplied element that exists in the JS context of the supplied window object (cntx) and waits the specified delayTime after clicking IFF the supplied element was non-null/undefined. |
|
public |
async clickWithDelay(elem: SomeElement, delayTime: number): Promise<boolean> Calls the click method of the supplied element and waits the specified delayTime after clicking IFF the supplied element was non-null/undefined. |
|
public |
collapseWhitespace(str: string): string Attempts to collapse all extra white space into a single white space character |
|
public |
collectOutlinksFrom(queryFrom: Element | Document) Collects outlinks form the supplied element |
|
public |
Collects the outlinks from the document |
|
public |
Composes multiple functions from right to left into a single function. |
|
public |
composeAsync(funcs: function(...args: *): Promise<*>): function(...args: *): Promise<*> Composes multiple async or Promise returning functions from right to left into a single function. |
|
public |
composeAsyncIterators(funcs: function(...args: *): AsyncIterator<*>): function(...args: *): AsyncIterator<*> Composes multiple AsyncIterator returning functions from right to left into a single function. |
|
public |
composeIterators(funcs: function(...args: *): Iterator<*>): function(...args: *): Iterator<*> Composes multiple Iterator returning functions from right to left into a single function. |
|
public |
createMouseEvent(config: CreateMouseEventOptions): MouseEvent Creates and returns a new mouse event configured using the supplied options |
|
public |
createScrollAmount(desiredTimesToScroll: number): {timesToScroll: number, scrollUpDownAmount: number, scrollLeftRightAmount: number} Creates and returns an object that calculates the scroll amount, up/down or left/right, based on dividing the scroll width/height by the supplied desired times to completely scroll the page, defaults to 10. |
|
public |
createScroller(timesToScroll: number): Scroller Creates and returns an object for scrolling the page up/down and left/right. |
|
public |
createState(wait: boolean, msg: *, state: *): BehaviorState Returns a behavior state object with the supplied wait and msg values. |
|
public |
Returns a Promise that resolves after waiting the amount of time specified by delayTime. |
|
public |
async * disconnectingWalk(walkState: DisconnectingWalkState): AsyncIterableIterator<*> Yields the child elements of the found parent element. |
|
public |
docBaseURIEndsWith(shouldEndWith: string, cntxDoc: Document): boolean Returns T/F indicating if the documents baseURI ends with the supplied string |
|
public |
docBaseURIEquals(shouldEqual: string, cntxDoc: Document): boolean Returns T/F indicating if the documents baseURI equals the supplied string |
|
public |
documentScrollPosition(doc: Document): {scrollTop: number, scrollLeft: number} Returns the scrollTop and scrollLeft values of the supplied document if one was supplied other wise the values are from the current document |
|
public |
domCompletePromise(): Promise<void> Returns a promise that resolves once
|
|
public |
doneOrWait(rawResults: RawBehaviorStepResults): BehaviorStepResults The default post step function used for all behaviors that do not provide one. |
|
public |
elemDataValue(elem: HTMLElement | SVGElement, dataKey: string): string Returns the value of the elements data attribute if it exists If the element is null/undefined or does not have data attributes null is returned. |
|
public |
elemDataValueEqs(elem: HTMLElement | SVGElement, dataKey: *, dataValue: *): boolean Returns T/F indicating if the element has data attribute equal to the supplied value |
|
public |
elemHasChildren(elem: Element): boolean Returns T/F indicating if the supplied element has children. |
|
public |
elemHasSibling(elem: SomeElement): boolean Returns T/F indicating if the supplied element has an sibling element |
|
public |
Determines if the supplied elements bounding client rect's x,y,width,height,top,left properties all equal zero. Note this function returns true if the element is null/undefined; |
|
public |
elemInnerText(elem: SomeElement, trim: boolean): string Returns the supplied elements innerText |
|
public |
elemInnerTextEqs(elem: SomeElement, shouldEqual: string, trim: boolean): boolean Returns T/F if the supplied elements innerText equals the supplied string case sensitive |
|
public |
elemInnerTextEqsInsensitive(elem: SomeElement, shouldEqual: string, trim: boolean): boolean Returns T/F if the supplied elements innerText equals the supplied string case in-sensitive |
|
public |
elemInnerTextEqsOneOf(elem: SomeElement, shouldEquals: ...string): boolean Returns T/F if the supplied elements innerText equals one of the supplied string case sensitive |
|
public |
elemInnerTextMatchesRegex(elem: SomeElement, regex: RegExp): boolean Returns T/F if the supplied elements innerText matches the supplied regex |
|
public |
elemMatchesSelector(elem: SomeElement, selector: string): boolean Returns T/F indicating if the element matches the supplied selector |
|
public |
elemOffsetTopZero(elem: SomeElement): boolean Returns true if the supplied elements |
|
public |
elemTextContent(elem: SomeElement): string Returns the textContent of the supplied element |
|
public |
elementTextContains(elem: SomeElement, needle: string, caseInsensitive: boolean): boolean Returns T/F indicating if the supplied element's textContents contains the supplied string |
|
public |
elementTextEndsWith(elem: SomeElement, end: string): boolean Returns T/F indicating if the supplied element's textContent ends with the supplied string |
|
public |
elementTextEqs(elem: SomeElement, shouldEqual: string, caseInsensitive: boolean): boolean Returns T/F indicating if the supplied element's textContents equals the supplied string |
|
public |
elementTextStartsWith(elem: SomeElement, start: string): boolean Returns T/F indicating if the supplied element's textContent starts with the supplied string |
|
public |
elementTextStartsWithAndEndsWith(elem: SomeElement, start: string, end: string): boolean Returns T/F indicating if the supplied element' textContent starts and ends with the supplied start and end strings |
|
public |
elementsNameEquals(elem: SomeElement, name: string): boolean Returns T/F indicating if the elements name (localName) is equal to the supplied name |
|
public |
extractProps(object: Object, props: ...string): Object Returns a new object with the properties of the object on the new object |
|
public |
filteredQs(selector: string, filterFn: function(elem: SomeElement): boolean, context: SomeElement | Document): SomeElement Utility function for |
|
public |
async findAllMediaElementsAndPlay(cntx: Document | Element): Promise<boolean> Calls the play function on all audio and video elements found in the document. |
|
public |
findChildWithKey(reactInstance: Object, key: string): Object Walks the children of a react component to find the one that has the supplied key |
|
public |
findDirectChildElement(parentElement: SomeElement, predicate: function(elem: SomeElement): boolean): SomeElement Applies the supplied |
|
public |
findReduxStore(startingComponent: Object): Object Attempts the find the redux store from the supplied component |
|
public |
findTag(xpg: function(query: string, node: ?Node): Node[], tag: string, predicate: function(elem: SomeElement): boolean, cntx: Document | SomeElement): SomeElement Attempts to find a tag using the supplied function that accepts an xpath query and an optional starting element and returns the element the supplied predicate function returns a truthy value for |
|
public |
fireEventOn(elem: Element, event: Event) Fires the supplied event on the supplied element |
|
public |
Creates mouse events and fires them in order configured using the supplied options |
|
public |
Returns the first child element of the supplied elements parent element. |
|
public |
Returns the supplied elements first element child. |
|
public |
firstChildElementOfSelector(selector: string, cntx: Document | SomeElement): SomeElement Returns the first child element of the element matching the supplied selector |
|
public |
getElemSibling(elem: SomeElement): SomeElement Returns the supplied elements next element sibling |
|
public |
Returns the supplied elements next element sibling and removes the supplied element |
|
public |
getElementClientPageCenter(element: SomeElement, options: {floor: boolean}): {clientY: number, clientX: number, pageY: number, pageX: number} Get the center of the passed DOM element |
|
public |
getElementClientPagePosition(element: SomeElement, options: Object): {clientY: number, clientX: number, pageY: number, pageX: number} Get the position of the passed DOM element |
|
public |
getElementPositionWidthHeight(element: Element, doc: Document): {y: number, pageY: number, x: number, pageX: number, w: number, h: number} Helper function to get the actual x and y position, page x and y position (scroll) and the height, width of a given element |
|
public |
Returns the next element sibling of the parent element of the supplied element |
|
public |
getInternalRootOnElem(elem: HTMLElement | Element | Node): Object Returns the internal root object added by react on the supplied element. |
|
public |
getNthParentElement(elem: SomeElement, nth: number): SomeElement Returns the Nth parent element of the supplied element (indexing assumes start is 1) |
|
public |
getReactRootContainer(elem: HTMLElement | Element | Node): Object Returns the root container object added by react |
|
public |
getReactRootHostElem(alternativeId: string): HTMLElement Returns the root host element of an react application (id = react-root) |
|
public |
getViaPath(obj: *, pathItems: *): * Retrieves the property of an object, or item in array at index, based on the supplied path. |
|
public |
globalWithPropsExist(global: string, props: ...string): boolean Returns T/F if an global property (on window) exists and has all properties. |
|
public |
hasAnyClass(elem: SomeElement, classes: ...string): boolean Tests to see if the supplied element has any of the supplied css classes |
|
public |
hasClass(elem: SomeElement, clazz: string): boolean Tests to see if the supplied element has a css class |
|
public |
hasClasses(elem: SomeElement, classes: ...string): boolean Tests to see if the supplied element has the supplied css classes |
|
public |
id(eid: string, context: SomeElement | Document): SomeElement Utility function for |
|
public |
Determines if the element the supplied id identifies exists |
|
public |
Performs the setup required for integration with Webrecorders automation system Adds as propeties to the supplied window object
|
|
public |
innerTextOfSelected(selector: string, cntx: SomeElement | Document): string Returns the inner text of the element the supplied selectors matches |
|
public |
Returns T/F indicating if the supplied string is only alpha characters |
|
public |
isAlphaNumeric(str: string): boolean Returns T/F indicating if the supplied string is only alpha numeric characters |
|
public |
isClasslessElem(elem: SomeElement): boolean Returns T/F indicating if the supplied element has not CSS classes |
|
public |
isElemVisible(elem: SomeElement): boolean Returns T/F indicating if the supplied element is visible. |
|
public |
isEmptyString(str: string): boolean Returns T/F indicating if the supplied string is truly an empty string |
|
public |
isFunction(obj: *): boolean Returns T/F indicating if the supplied arument is a function |
|
public |
isGenerator(obj: *): boolean Returns T/F indicating if the supplied object is a generator or async generator |
|
public |
Returns T/F indicating if the supplied string is only lowercase alpha characters |
|
public |
Returns T/F indicating if the supplied string only contains numeric characters |
|
public |
Returns T/F indicating if the supplied object is a Promise or Promise like |
|
public |
Returns T/F indicating if the supplied string is only uppercase alpha characters |
|
public |
lastChildElementOf(elem: SomeElement): SomeElement Returns the last child element of the supplied element |
|
public |
lastChildElementOfSelector(selector: string, cntx: Document | SomeElement): SomeElement Returns the last child element of the element the selector selects |
|
public |
locationContains(something: string): boolean Determines if |
|
public |
locationEquals(someLocation: string): boolean Determines the strict equality of the string
to the value of |
|
public |
async * mapAsyncIterator(iterator: AsyncIterableIterator<*>, mapper: function(arg: *): *): AsyncIterableIterator<*> Like map for arrays but over async-iterators |
|
public |
markElemAsVisited(elem: SomeElement, marker: string) Marks the supplied element as visited by adding the marker to its classList. |
|
public |
maybePolyfillXPG(cliXPG: function(...args: *): Array<SomeElement>): function(...args: *): Array<SomeElement> Ensures that if the value of the chrome console utility $x is not the actual utility (jquery is on the page) the returned function behaves exactly like it. |
|
public |
maybeRemoveElem(selector: string, context: SomeElement | Document): boolean Removes the element selected by the supplied querySelector, if it exits, returning true to indicate the element was removed and false otherwise |
|
public |
maybeRemoveElemById(eid: string, context: SomeElement | Document): boolean Removes the element with the supplied id, if it exits, returning true to indicate the element was removed and false otherwise |
|
public |
async * noExceptGeneratorWrap(generator: AsyncIterableIterator<*>|IterableIterator<*>, returnLast: boolean): AsyncIterableIterator<*> Wraps the supplied generator in a try catch and re-yields its values generator. |
|
public |
async noExceptPlayMediaElement(mediaElement: HTMLMediaElement, playThrough: boolean): Promise<boolean> Calls the play function of the supplied element catching the exception thrown if any was thrown. |
|
public |
nodesNameEquals(node: SomeElement, name: string): boolean Returns T/F indicating if the nodes name (nodeName) is equal to the supplied name |
|
public |
noop() This function is a no op |
|
public |
nthChildElementOf(elem: SomeElement | Document, nth: number): SomeElement Returns the Nth child element of the supplied element (indexing assumes start is 1) |
|
public |
nthChildNodeOf(elem: SomeElement | Document, nth: number): SomeElement Returns the Nth child node of the supplied element (indexing assumes start is 1) |
|
public |
nthPreviousSibling(elem: SomeElement, nth: number): SomeElement Returns the nth previous sibling of the supplied element if it is not null/undefined or the supplied element is not null/undefined |
|
public |
numElemChildren(elem: SomeElement): number Returns the number of child elements the supplied element has if it is not null/undefined otherwise -1 |
|
public |
objectHasProps(obj: Object, props: ...string): boolean Returns T/F if the supplied object has all of the supplied properties. |
|
public |
objectInstanceOf(obj: Object, shouldBeInstanceOfThis: Object): boolean Returns T/F indicating if the supplied object is an instance of some class. |
|
public |
Creates and returns a partially applied function with args being applied left to right |
|
public |
partialRight(fn: function, a1: *, a2: *, a3: *, a4: *, a5: *, aN: ...*): function(...args: *): * Creates and returns a partially applied function with args being applied right to left |
|
public |
promiseResolveReject(): {resolve: function, reject: function, promise: Promise<*>} Creates a Promise that is resolvable externally returning an object that exposes the promise itself and the resolve and reject functions passed as arguments to the executor function |
|
public |
qs(selector: string, context: SomeElement | Document): SomeElement Utility function for |
|
public |
qsOneOf(options: {selectors: Array<string>, context: *}): SomeElement Returns the results of querySelector using one of the supplied selectors one if one of the selectors yields results otherwise null/undefined |
|
public |
qsa(selector: string, context: SomeElement | Document): NodeList<SomeElement> Utility function for |
|
public |
qsaOneOf(options: {selectors: Array<string>, context: *}): NodeList<SomeElement> Returns the results of querySelectorAll using one of the supplied selectors if one of the selectors yields results otherwise null/undefined |
|
public |
reactInstanceFromDOMElem(elem: HTMLElement | Element | Node): Object Returns the react instance object that lives on the live element |
|
public |
reactInstancesFromElements(elems: Array<Node|HTMLElement|Element>, selectingFn: function(key: string): boolean): Array<{node: HTMLElement|Element|Node, reactInstance: Object}> Converts the supplied array of elements into an array of objects each with property node (the live dom element) and reactInstance (the live react component). |
|
public |
removeClass(elem: SomeElement, clazz: string) Removes a CSS classname to the supplied element |
|
public |
* repeatedXpathQueryIterator(query: string, cntx: *, generateMoreElements: function(): void): IterableIterator<SomeElement> Repeatably performs the supplied xpath query yielding the results of the each query. |
|
public |
async * repeatedXpathQueryIteratorAsync(query: string, cntx: *, generateMoreElements: function(): *): AsyncIterableIterator<SomeElement> Repeatably performs the supplied xpath query yielding the results of the each query. |
|
public |
resolveWhenBehaviorUnPaused(): Promise<any> Returns a Promise that resolves once the behavior has been un-paused |
|
public |
scrollAllIntoViewAndClick(elems: Array<HTMLElement>): number Scrolls into view and clicks all the elements present in the supplied array. |
|
public |
async scrollAllIntoViewAndClickWithDelay(elems: Array<HTMLElement|Element|Node>, delayTime: number): Promise<void> Scrolls into view and clicks all the elements present in the supplied array waiting for the supplied delay time after each click of an element in the array. |
|
public |
scrollDownByElemHeight(elem: Element | HTMLElement | Node): void Scrolls down by the elements height |
|
public |
scrollDownByElemHeightWithDelay(elem: Element | HTMLElement | Node, delayTime: number): Promise<void> Scrolls down by supplied elements height and then waits for the supplied delay time. |
|
public |
scrollIntoView(elem: Element, opts: Object): void Scrolls the supplied element into view. |
|
public |
scrollIntoViewAndClick(elem: HTMLElement | Element): boolean Scrolls the supplied element into view and clicks it if the element is non-null/undefined |
|
public |
scrollIntoViewAndClickWithDelay(elem: HTMLElement | Element, delayTime: number): Promise<boolean> Scrolls the supplied element into view and clicks it if the element is non-null/undefined and waits for the specified delay time |
|
public |
scrollIntoViewAndWaitFor(elem: Element | HTMLElement | Node, predicate: function(): boolean, options: {wait: ?WaitForOptions, scrollBehavior: ?Object}): Promise<{predicate: boolean, maxExceeded: boolean}>{predicate:> Scrolls the supplied element into view and then waits for the supplied predicate function to return true |
|
public |
scrollIntoViewWithDelay(elem: Element | HTMLElement | Node, delayTime: number): Promise<void> Scrolls the supplied element into view, afterwards waits for the specified delay time |
|
public |
scrollToElemOffset(elem: Element | HTMLElement | Node, behavior: string): void Scrolls the window by the supplied elements offsetTop. |
|
public |
scrollToElemOffsetWithDelay(elem: Element | HTMLElement | Node, delayTime: number): Promise<void> Scrolls the window by the supplied elements offsetTop. |
|
public |
scrollWindowBy(x: number, y: number) Scrolls the window by the supplied x and y amount |
|
public |
scrollWindowByWithDelay(x: number, y: number, delayTime: number): Promise<void> Scrolls the window by the supplied x and y amount |
|
public |
scrollWindowDownBy(amount: number) Scrolls the window down by the supplied amount |
|
public |
scrollWindowDownByWithDelay(amount: number, delayTime: number): Promise<void> Scrolls the window down by the supplied amount |
|
public |
Converts the supplied n number of seconds into milliseconds which is required for setTimeout and setInterval |
|
public |
selectAllAndClick(selector: string, context: Element): boolean Selects all elements that match the supplied selector and clicks them returning T/F indicating if a click happened on any selected element |
|
public |
async selectAllAndClickWithDelay(opts: {selector: string, cntx: *, delayTime: *}): boolean Selects all elements that match the supplied selector and clicks them returning T/F indicating if a click happened on any selected element |
|
public |
selectAndPlay(selector: string, cntx: Document | Element): Promise<boolean> Calls the play method of the element returned by the querySelector |
|
public |
selectClickAndWaitFor(selector: string, predicate: function(): boolean, selectFrom: HTMLElement | Document): Promise<{predicate: boolean, maxExceeded: boolean, clicked: boolean}>{predicate:> Clicks the element returned by calling querySelector using the selector on document or the supplied element (selectFrom) and then waits for the supplied predicate function to return true |
|
public |
selectElemAndClick(selector: string, cntx: *): boolean Clicks the element from executing document.querySelector using the supplied selector |
|
public |
selectElemAndClickWithDelay(selector: string, delayTime: number): Promise<boolean> Clicks the element from executing document.querySelector using the supplied selector and waiting the specified delay time after clicking |
|
public |
selectElemFromAndClick(selectFrom: Element | Node | HTMLElement, selector: string): boolean Clicks the element from executing querySelector using the supplied selector using the supplied element |
|
public |
selectElemFromAndClickWithDelay(selectFrom: Element | Node | HTMLElement, selector: string, delayTime: number): Promise<boolean> Clicks the element from executing querySelector using the supplied selector from the supplied element and waiting the specified delay time after clicking |
|
public |
selectFromAndClickNTimes(selectFrom: Element, selector: string, n: number): number Clicks the element returned from result of calling querySelector using the supplied selector on the supplied element N number of times. |
|
public |
async selectFromAndClickNTimesWithDelay(selectFrom: Element, selector: string, n: number, delayTime: number): Promise<number> Clicks the element returned from result of calling querySelector using the supplied selector on the supplied element N number of times and waits for delay time afters each click. |
|
public |
async selectFromAndClickUntilNullWithDelay(selectFrom: Element, selector: string, options: {delay: number, max: ?number}): Promise<number> Clicks the element returned from result of calling querySelector using the supplied selector on the supplied element until the results of the evaluting the selector returns null/undefined, waiting for delay time afters each click. |
|
public |
selectIdAndPlay(eid: string, cntx: Document): Promise<boolean> Calls the play method of the element returned by calling document.getElementById |
|
public |
selectScrollIntoViewAndClickSelectedWhileConnected(selector: string, options: SelectScrollIntoViewClickUntilNullOptions): void Like selectFromAndClickUntilNullWithDelay but will stop selecting and clicking the selected element if the current reference becomes disconnected from the dom or the optional stopPredicate returns true. |
|
public |
async selectScrollIntoViewAndClickWithDelayWhileSelectedConnected(selector: string, options: SelectScrollIntoViewClickUntilNullOptions): Promise<void> Like selectFromAndClickUntilNullWithDelay but will stop selecting and clicking the selected element if the current reference becomes disconnected from the dom or the optional stopPredicate returns true. |
|
public |
selectedNextElementSibling(selector: string, context: SomeElement | Document): SomeElement Returns the next element sibling of the supplied selector IFF the selector returns a results and the next element sibling exists otherwise null/undefined |
|
public |
selectorExists(selector: string, cntx: Document | SomeElement): boolean Determines if the element the supplied selector selects exists |
|
public |
sendAutoFetchWorkerURLs(urls: Array<string>) Sends the supplied array of URLs to the backing pywb/webrecorder auto-fetch worker if it exists |
|
public |
setIntervalP(callback: *, timeout: *): number Polls the supplied function at the timeout rate only if the behavior is not paused |
|
public |
setTimeoutP(callback: *, timeout: *): number Like setTimeout except that the timeout respects the pause state of the behavior |
|
public |
smoothScrollWindowBy(x: number, y: number) Scrolls the window by the supplied x and y amount smoothly |
|
public |
smoothScrollWindowDownBy(amount: number) Scrolls the window down by the supplied amount smoothly |
|
public |
splitElemInnerText(elem: SomeElement, splitter: string | RegExp): Array<string> Returns the results of splitting the supplied elements innerText using the supplied splitter |
|
public |
splitElemTextContents(elem: SomeElement, splitter: string | RegExp): Array<string> Returns the results of splitting the supplied elements textContent using the supplied splitter |
|
public |
stateWithMsgNoWait(msg: string, state: *): BehaviorState Returns a behavior state object with the supplied msg indicating the behavior runner should not wait for network idle. |
|
public |
stateWithMsgWait(msg: string, state: *): BehaviorState Returns a behavior state object with the supplied msg indicating the behavior runner should wait for network idle. |
|
public |
async stateWithMsgWaitFromAwaitable(awaitable: Promise<boolean>, msg: *, state: *): Promise<BehaviorState> Returns a Promise that resolves to an behavior state object with the supplied msg with the wait value being set by the value resolved Promise. |
|
public |
stateWithMsgWaitFromFn(fn: function(): boolean, msg: *, state: *): BehaviorState Returns a behavior state object with the supplied msg with the wait value being set by the return value of the supplied function. |
|
public |
stringBetween(str: string, left: string, right: string): string Returns the string between the left and right string |
|
public |
substringFromIndexOf(str: string, needle: string, opts: SubstringArgs): string Returns the substring from the index of the supplied needle |
|
public |
substringFromLastIndexOf(str: string, needle: string, opts: SubstringArgs): string Returns the substring from the last index of the supplied needle |
|
public |
Attempts to convert the supplied string into title case |
|
public |
Attempts to convert the supplied string to boolean (true, yes, on, 1) |
|
public |
Attempts to convert the supplied string to a float |
|
public |
Attempts to convert the supplied string to a integer |
|
public |
async * traverseChildrenOf(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> Applies a function to the children of the supplied parent element yielding the return value of the function. |
|
public |
async * traverseChildrenOfCustom(opts: TraversalOpts): AsyncIterableIterator<*> Traverses the children of the supplied element applying the supplied function to each child and yielding the return value of the function. |
|
public |
async * traverseChildrenOfLoaderParent(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> Applies a function to the children of the supplied parent element yielding the return value of the function. |
|
public |
async * traverseChildrenOfLoaderParentGenFn(parentElement: SomeElement, genFn: function(): BoolOrPromiseBool, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> Applies a function to the children of the supplied parent element yielding the return value of the function. |
|
public |
async * traverseChildrenOfLoaderParentRemovingPrevious(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> Applies a function to the children of the supplied parent element yielding the return value of the function and then removing the previously considered child element from the DOM. |
|
public |
async * traverseChildrenOfRemovingPrevious(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> Applies a function to the children of the supplied parent element yielding the return value of the function and then removing the previously considered child element from the DOM. |
|
public |
uaThinksMediaElementCanPlayAllTheWay(mediaElement: HTMLMediaElement): Promise<void> Returns a promise that resolves once the canplaythrough or error event is fired from the supplied media element |
|
public |
Creates and returns a valid uuid v4 |
|
public |
waitForAdditionalElemChildren(parentElement: SomeElement, options: WaitForOptions): Promise<WaitResult> Waits for the number children of the supplied parentElement
to become greater than the supplied parent elements |
|
public |
waitForAdditionalElemChildrenMO(parentElement: SomeElement, options: GuardedWaitForOptions): Promise<WaitResult> Waits for additional child elements to be added to the supplied parentElement using a mutation observer. |
|
public |
async waitForAndSelectElement(fromNode: SomeElement, selector: string, options: WaitForOptions): PromiseSomeElement> Calls |
|
public |
waitForEventTargetToFireEvent(eventTarget: EventTarget, event: string, max: number): Promise<boolean> Returns a promise that resolves to true once the supplied event is fired from the supplied event target. |
|
public |
waitForHistoryManipToChangeLocation(previousLocation: string, options: WaitForOptions): Promise<boolean> Waits for the value of |
|
public |
waitForPredicate(predicate: function(): boolean, options: WaitForOptions): Promise<WaitResult> Returns a promise that resolves once the supplied predicate function returns a truthy value. |
|
public |
waitForSelector(config: WaitForSelectorOptions): Promise<WaitResult> Waits for the supplied selector to exist |
|
public |
waitUntilElementIsRemovedFromDom(elem: SomeElement, options: WaitForOptions): Promise<WaitResult> Waits for the supplied element to be removed from the document. |
|
public |
async * walkChildrenOfCustom(opts: WalkChildrenOfCustomOpts): AsyncIterableIterator<SomeElement> Walks the children of the supplied parent element yielding its children. |
|
public |
xpathOneOf(options: XPathOnOfOpts): Array<SomeElement> Returns the results of evaluating one of the supplied xpath queries if one of the queries yields results otherwise null/undefined |
|
public |
xpathSnapShot(xpathQuery: string, contextElement: SomeElement | Document): XPathResult Returns the results of evaluating the supplied
xpath query using an optional context |
|
public |
xpathSnapShotArray(xpathQuery: string, contextElement: SomeElement | Document): Array<SomeElement> Provides the same functionality of the chrome console utility |
Static Public
public addBehaviorStyle(styleDef: string): Object source
import {addBehaviorStyle} from 'lib/dom.js'
Creates a style tag if one was not created before and adds
the supplied styleDef
to it. If a style tag was created before
this function is a no-op
Params:
Name | Type | Attribute | Description |
styleDef | string | The CSS rules to add |
Return:
Object | An object containing the selectors as key value pairs where the keys are the selectors in camelcase and the value is the raw selector |
public addClass(elem: SomeElement, clazz: string) source
import {addClass} from 'lib/dom.js'
Adds a CSS classname to the supplied element
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element to add the classname to |
clazz | string | The classname to be added |
public addOutLinks(toAdd: Array<HTMLAnchorElement|HTMLAreaElement>|NodeList<HTMLAnchorElement|HTMLAreaElement>) source
import {addOutLinks} from 'lib/outlinkCollector.js'
Add the array/nodelist of A or Anchor tags href properties the collected outlinks
Params:
Name | Type | Attribute | Description |
toAdd | Array<HTMLAnchorElement|HTMLAreaElement>|NodeList<HTMLAnchorElement|HTMLAreaElement> | The elements with href properties that are to be added to the collected outlinks |
public addOutlink(elemOrString: HTMLAnchorElement | HTMLAreaElement | string) source
import {addOutlink} from 'lib/outlinkCollector.js'
Add the URL or href value of the supplied argument
Params:
Name | Type | Attribute | Description |
elemOrString | HTMLAnchorElement | HTMLAreaElement | string | The element with href property or string to add to the collected outlinks |
public anySelectorExists(selectors: Array<string>, cntx: SomeElement): {idx: number, success: boolean} source
import {anySelectorExists} from 'lib/dom.js'
Determines if the element the supplied selector selects exists.
If one of the supplied selectors matches an existing element the idx property of the returned object is set to the index of the selector in the array and the success property is set to true.
Otherwise idx = -1 and success = false.
Params:
Name | Type | Attribute | Description |
selectors | Array<string> | The query selectors to use for testing if the elements it selects exist |
|
cntx | SomeElement |
|
Optional element to use rather than the current JS context's document object |
public attr(elem: SomeElement, attr: string): * source
import {attr} from 'lib/dom.js'
Retrieves the value of an elements attribute if it exists
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to retrieve an attribute from |
|
attr | string | The name of the attribute to be retrieved |
Return:
* | The value of the retrieved attribute if it exists |
public attrEq(elem: SomeElement, attr: string, shouldEq: *): boolean source
import {attrEq} from 'lib/dom.js'
Tests to determine if the value of elements attribute equals the supplied value using loose equality
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to retrieve an attribute from |
|
attr | string | The name of the attribute to be retrieved |
|
shouldEq | * | The value the attributes value should equal |
Return:
boolean | T/F indicating if the attribute equals. Note false can indicate the attribute does not equal expected or the element was null/undefined |
public autoFetchFromDoc() source
import {autoFetchFromDoc} from 'lib/general.js'
Initiates an pywb/webrecorder auto-fetch of content
public autobind(clazz: *) source
import {autobind} from 'lib/general.js'
Automatically binds the non-inherited functions of the supplied class to itself.
Params:
Name | Type | Attribute | Description |
clazz | * |
public browserHistoryGoBack() source
import {browserHistoryGoBack} from 'lib/browser.js'
Navigate the browser back 1 entry in the history stack. This may cause navigation.
public browserLocation(): string source
import {browserLocation} from 'lib/browser.js'
Returns the value window.location.href
public buildCustomPostStepFn(customFN: function(rawResults: RawBehaviorStepResults): void): function(state: RawBehaviorStepResults): BehaviorStepResults source
import {buildCustomPostStepFn} from 'lib/postStepFNs.js'
Creates and returns a function wrapping the provided post step function will call the supplied function and return the expected output.
Params:
Name | Type | Attribute | Description |
customFN | function(rawResults: RawBehaviorStepResults): void |
public camelCase(str: string): string source
import {camelCase} from 'lib/strings.js'
Attempts to convert the supplied string into camel case
Params:
Name | Type | Attribute | Description |
str | string |
public camelCaseToDashDelim(str: string): string source
import {camelCaseToDashDelim} from 'lib/strings.js'
Attempts to convert the supplied camel case string into dash delimited string
Params:
Name | Type | Attribute | Description |
str | string |
|
public camelCaseToUnderscoreDelim(str: string): string source
import {camelCaseToUnderscoreDelim} from 'lib/strings.js'
Attempts to convert the supplied camel case string into an underscore delimited string
Params:
Name | Type | Attribute | Description |
str | string |
|
public canAccessIf(iframe: HTMLIFrameElement): boolean source
import {canAccessIf} from 'lib/dom.js'
Determines if the supplied iframe is accessible from this origin. Test is that access the window object of the iframes contentWindow does not throw an exception and the contentDocument is not falsy.
Params:
Name | Type | Attribute | Description |
iframe | HTMLIFrameElement | The iframe to determine accessibility |
public canScrollDownMore(): boolean source
import {canScrollDownMore} from 'lib/scrolls.js'
Determines if we can scroll down any more
public canScrollUpMore(): boolean source
import {canScrollUpMore} from 'lib/scrolls.js'
Determines if we can scroll up any more
public capitalize(str: string): string source
import {capitalize} from 'lib/strings.js'
Attempts to capitalize the supplied string
Params:
Name | Type | Attribute | Description |
str | string |
public chainFistChildElemOf(elem: SomeElement, times: number): SomeElement source
import {chainFistChildElemOf} from 'lib/dom.js'
Chains firstChildElementOf on the supplied element n times
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The starting element |
|
times | number | How many times to call firstChildElementOf |
public chainLastChildElemOf(elem: SomeElement, times: number): SomeElement source
import {chainLastChildElemOf} from 'lib/dom.js'
Chains lastChildElementOf n times
starting with the supplied element
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The starting parent element who |
|
times | number | How many times should the |
public chainNthChildElementOf(elem: SomeElement, nths: ...number): SomeElement source
import {chainNthChildElementOf} from 'lib/dom.js'
Chains nthChildElementOf for each nth child element in nths
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The starting parent element |
|
nths | ...number | The consecutive nth child node |
Example:
// child is the parent elements 3rd child element's 4th child element's 5th child element
const child = chainNthChildElementOf(parentElement, 3, 4, 5);
public chainNthChildNodeOf(startingElem: SomeElement, nths: ...number): SomeElement source
import {chainNthChildNodeOf} from 'lib/dom.js'
Chains nthChildElemOf for each nth child in nths
Params:
Name | Type | Attribute | Description |
startingElem | SomeElement | The starting parent element |
|
nths | ...number | The consecutive nth child node |
Example:
// child is the parent elements 3rd child node's 4th child node's 5th child node
const child = chainNthChildNodeOf(parentElement, 3, 4, 5);
public chainQs(startingSelectFrom: SomeElement | Document, startingSelector: string, selectors: ...string): SomeElement source
import {chainQs} from 'lib/dom.js'
Consecutively calls querySelector(selector) on the element returned by the previous invocation
Params:
Name | Type | Attribute | Description |
startingSelectFrom | SomeElement | Document | The first element to perform querySelector(startingSelector) on |
|
startingSelector | string | The first selector |
|
selectors | ...string | Additional selections |
public * childElementIterator(parentElement: SomeElement): IterableIterator<SomeElement> source
import {childElementIterator} from 'lib/dom.js'
Returns an iterator over the supplied parent element's child elements that ends once the current child has no next element sibling.
If the parent element is null/undefined then the returned iterator yields nothing.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's child elements will be iterated over |
public * childNodeIterator(parentElement: SomeElement): IterableIterator<Node> source
import {childNodeIterator} from 'lib/dom.js'
Returns an iterator over the supplied parent element's child nodes that ends once the current child has no next sibling.
If the parent element is null/undefined then the returned iterator yields nothing.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's child nodes will be iterated over |
public click(elem: SomeElement): boolean source
import {click} from 'lib/clicks.js'
Calls the click function on the supplied element if non-null/defined. Returns true or false to indicate if the click happened
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element to be clicked |
public async clickAndWaitFor(elem: Element | Node | HTMLElement, predicate: function(): boolean, options: WaitForOptions): Promise<{predicate: boolean, maxExceeded: boolean, clicked: boolean}>{predicate:> source
import {clickAndWaitFor} from 'lib/clicks.js'
Clicks the supplied element and then waits for the supplied predicate function to return true
Params:
Name | Type | Attribute | Description |
elem | Element | Node | HTMLElement | the element to be clicked |
|
predicate | function(): boolean | function returning true or false indicating the wait condition is satisfied |
|
options | WaitForOptions |
|
Options controlling how the wait will happen |
public async clickAndWaitForHistoryChange(elemToBeClicked: Element | HTMLElement, waitOpts: WaitForOptions): Promise<{oldlocation: ?string, historyChanged: boolean, clicked: boolean, newLocation: ?string, ok: boolean}>{oldlocation:> source
import {clickAndWaitForHistoryChange} from 'lib/clicks.js'
Clicks the supplied element and waits for browser history to change (the URL is updated by JavaScript modifying the current history stack)
Params:
Name | Type | Attribute | Description |
elemToBeClicked | Element | HTMLElement | the Element to be click |
|
waitOpts | WaitForOptions |
|
options controlling the wait |
public clickInContext(elem: SomeElement, cntx: Window): boolean source
import {clickInContext} from 'lib/clicks.js'
Calls the click function on the supplied element if non-null/defined that exists in the JS context of the supplied window (cntx). Returns true or false to indicate if the click happened
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to be clicked |
|
cntx | Window | The context window |
public async clickInContextWithDelay(elem: HTMLElement | Element, cntx: Window, delayTime: number): Promise<boolean> source
import {clickInContextWithDelay} from 'lib/clicks.js'
Calls the click method of the supplied element that exists in the JS context of the supplied window object (cntx) and waits the specified delayTime after clicking IFF the supplied element was non-null/undefined.
public async clickWithDelay(elem: SomeElement, delayTime: number): Promise<boolean> source
import {clickWithDelay} from 'lib/clicks.js'
Calls the click method of the supplied element and waits the specified delayTime after clicking IFF the supplied element was non-null/undefined.
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element to be clicked |
delayTime | number |
|
How long is the delay after click |
public collapseWhitespace(str: string): string source
import {collapseWhitespace} from 'lib/strings.js'
Attempts to collapse all extra white space into a single white space character
Params:
Name | Type | Attribute | Description |
str | string |
public collectOutlinksFrom(queryFrom: Element | Document) source
import {collectOutlinksFrom} from 'lib/outlinkCollector.js'
Collects outlinks form the supplied element
Params:
Name | Type | Attribute | Description |
queryFrom | Element | Document | The element to collect outlinks from |
public collectOutlinksFromDoc() source
import {collectOutlinksFromDoc} from 'lib/outlinkCollector.js'
Collects the outlinks from the document
public compose(funcs: function(...args: *): *): function(...args: *): * source
import {compose} from 'lib/general.js'
Composes multiple functions from right to left into a single function. The rightmost function can take multiple arguments with the remaining functions taking only a single argument, the return value of the previous invocation.
Params:
Name | Type | Attribute | Description |
funcs | function(...args: *): * | The functions to compose. |
Return:
function(...args: *): * | A function obtained by composing the functions from right to left. For example, compose(f, g, h) is identical to doing (...args) => f(g(h(...args))). |
public composeAsync(funcs: function(...args: *): Promise<*>): function(...args: *): Promise<*> source
import {composeAsync} from 'lib/general.js'
Composes multiple async or Promise returning functions from right to left into a single function. The rightmost function can take multiple arguments with the remaining functions taking only a single argument, the return value of the previous invocation.
public composeAsyncIterators(funcs: function(...args: *): AsyncIterator<*>): function(...args: *): AsyncIterator<*> source
import {composeAsyncIterators} from 'lib/general.js'
Composes multiple AsyncIterator returning functions from right to left into a single function. The rightmost function can take multiple arguments with the remaining functions taking only a single argument, the iterator returned by the previous invocation. The composition of AsyncIterator can thought of as chaining multiple AsyncIterator together, that is to say feeding the yielded results of each iterator from right to left. This can be useful for chaining cascading asynchronous ordered actions.
Params:
Name | Type | Attribute | Description |
funcs | function(...args: *): AsyncIterator<*> | The AsyncIterator returning functions to be composed (chained) |
Return:
function(...args: *): AsyncIterator<*> | A function obtained by composing the functions from right to left. See the documentations example for details |
Example:
async function* iter1(iter) {
console.log('start iter1');
for await (const value of iter) {
yield `iter1 got "${value}" from the previous iter`;
}
yield 'end iter1';
}
async function* iter2(iter) {
console.log('start iter2');
for await (const value of iter) {
yield `iter2 got "${value}" from the previous iter`;
}
yield 'end iter2';
}
async function* iter3(...args) {
console.log('start iter3');
let i = args.length;
while (i--) {
yield args[i];
}
yield 'end iter3';
}
const finalAIter = composeAsyncIterators(iter1, iter2, iter3)(1, 2, 3, 4, 5);
(async () => {
for await (const it of finalAIter) {
console.log(it);
}
})();
// The output is as follows
// logs "start iter" from iter1
// logs "start iter2" from iter2
// logs "start iter3" from iter3
// logs 'iter1 got "iter2 got "5" from the previous iter" from the previous iter' from the for await of finalAiter
// logs 'iter1 got "iter2 got "4" from the previous iter" from the previous iter' from the for await of finalAiter
// logs 'iter1 got "iter2 got "3" from the previous iter" from the previous iter' from the for await of finalAiter
// logs 'iter1 got "iter2 got "2" from the previous iter" from the previous iter' from the for await of finalAiter
// logs 'iter1 got "iter2 got "1" from the previous iter" from the previous iter' from the for await of finalAiter
// logs 'iter1 got "iter2 got "end iter3" from the previous iter" from the previous iter' from the for await of finalAiter
// logs 'iter1 got "end iter2" from the previous iter' from the for await of finalAiter
// logs 'end iter1' from the for await of finalAiter
public composeIterators(funcs: function(...args: *): Iterator<*>): function(...args: *): Iterator<*> source
import {composeIterators} from 'lib/general.js'
Composes multiple Iterator returning functions from right to left into a single function. The rightmost function can take multiple arguments with the remaining functions taking only a single argument, the iterator returned by the previous invocation. The composition of iterators can thought of as chaining multiple iterators together, that is to say feeding the yielded results of each iterator from right to left. This can be useful for chaining cascading ordered actions.
Params:
Name | Type | Attribute | Description |
funcs | function(...args: *): Iterator<*> | The Iterator returning functions to be composed (chained) |
Return:
function(...args: *): Iterator<*> | A function obtained by composing the functions from right to left. See the documentations example for details |
Example:
function* iter1(iter) {
console.log('start iter1');
for (const value of iter) {
yield `iter1 got "${value}" from the previous iter`;
}
yield 'end iter1';
}
function* iter2(iter) {
console.log('start iter2');
for (const value of iter) {
yield `iter2 got "${value}" from the previous iter`;
}
yield 'end iter2';
}
function* iter3(...args) {
console.log('start iter3');
let i = args.length;
while (i--) {
yield args[i];
}
yield 'end iter3';
}
const finalIter = composeIterators(iter1, iter2, iter3)(1, 2, 3, 4, 5);
for (const it of finalIter) {
console.log(it);
}
// The output is as follows
// logs "start iter" from iter1
// logs "start iter2" from iter2
// logs "start iter3" from iter3
// logs 'iter1 got "iter2 got "5" from the previous iter" from the previous iter' from the for of finalIter
// logs 'iter1 got "iter2 got "4" from the previous iter" from the previous iter' from the for of finalIter
// logs 'iter1 got "iter2 got "3" from the previous iter" from the previous iter' from the for of finalIter
// logs 'iter1 got "iter2 got "2" from the previous iter" from the previous iter' from the for of finalIter
// logs 'iter1 got "iter2 got "1" from the previous iter" from the previous iter' from the for of finalIter
// logs 'iter1 got "iter2 got "end iter3" from the previous iter" from the previous iter' from the for of finalIter
// logs 'iter1 got "end iter2" from the previous iter' from the for of finalIter
// logs 'end iter1' from the for of finalIter
public createMouseEvent(config: CreateMouseEventOptions): MouseEvent source
import {createMouseEvent} from 'lib/events.js'
Creates and returns a new mouse event configured using the supplied options
Params:
Name | Type | Attribute | Description |
config | CreateMouseEventOptions |
Return:
MouseEvent |
public createScrollAmount(desiredTimesToScroll: number): {timesToScroll: number, scrollUpDownAmount: number, scrollLeftRightAmount: number} source
import {createScrollAmount} from 'lib/scrolls.js'
Creates and returns an object that calculates the scroll amount, up/down or left/right, based on dividing the scroll width/height by the supplied desired times to completely scroll the page, defaults to 10.
The calculation also takes into account the fact that the height or width of the document may change and reacts to those changes such that the returned scroll amount is always proportional to the documents current maximum scroll height or width
Params:
Name | Type | Attribute | Description |
desiredTimesToScroll | number |
|
How many scrolls until the maximum scroll position is reached |
public createScroller(timesToScroll: number): Scroller source
import {createScroller} from 'lib/scrolls.js'
Creates and returns an object for scrolling the page up/down and left/right. The number of times a respective scroll has occurred is also tracked.
For additional details see the documentation of createScrollAmount as the amount of scroll applied is determined the object it returns.
Params:
Name | Type | Attribute | Description |
timesToScroll | number |
|
How many scrolls until the maximum scroll position is reached |
public createState(wait: boolean, msg: *, state: *): BehaviorState source
import {createState} from 'lib/behaviorState.js'
Returns a behavior state object with the supplied wait and msg values. The value returned should be yield'd to the behavior runner
Params:
Name | Type | Attribute | Description |
wait | boolean | ||
msg | * | A message from the behavior representing a description of the action just performed |
|
state | * |
|
Any additional information about the full state of the behavior |
public delay(delayTime: number): Promise<void> source
import {delay} from 'lib/delays.js'
Returns a Promise that resolves after waiting the amount of time specified by delayTime.
Params:
Name | Type | Attribute | Description |
delayTime | number |
|
The length of the delay in milliseconds |
public async * disconnectingWalk(walkState: DisconnectingWalkState): AsyncIterableIterator<*> source
import {disconnectingWalk} from 'lib/traversals.js'
Yields the child elements of the found parent element. If the parent element becomes removed from the DOM after yielding the current child, the parent element and current child are re-found.
Params:
Name | Type | Attribute | Description |
walkState | DisconnectingWalkState |
Return:
AsyncIterableIterator<*> |
public docBaseURIEndsWith(shouldEndWith: string, cntxDoc: Document): boolean source
import {docBaseURIEndsWith} from 'lib/dom.js'
Returns T/F indicating if the documents baseURI ends with the supplied string
Params:
Name | Type | Attribute | Description |
shouldEndWith | string | What the documents base URI should end with |
|
cntxDoc | Document |
|
Optional document object to use rather than defaulting to the current execution contexts document object |
public docBaseURIEquals(shouldEqual: string, cntxDoc: Document): boolean source
import {docBaseURIEquals} from 'lib/dom.js'
Returns T/F indicating if the documents baseURI equals the supplied string
Params:
Name | Type | Attribute | Description |
shouldEqual | string | What the documents base URI should be equal to |
|
cntxDoc | Document |
|
Optional document object to use rather than defaulting to the current execution contexts document object |
public documentScrollPosition(doc: Document): {scrollTop: number, scrollLeft: number} source
import {documentScrollPosition} from 'lib/dom.js'
Returns the scrollTop and scrollLeft values of the supplied document if one was supplied other wise the values are from the current document
Params:
Name | Type | Attribute | Description |
doc | Document |
|
public domCompletePromise(): Promise<void> source
import {domCompletePromise} from 'lib/delays.js'
Returns a promise that resolves once
document.readyState === 'complete'
public doneOrWait(rawResults: RawBehaviorStepResults): BehaviorStepResults source
import {doneOrWait} from 'lib/postStepFNs.js'
The default post step function used for all behaviors that do not provide one.
Params:
Name | Type | Attribute | Description |
rawResults | RawBehaviorStepResults |
public elemDataValue(elem: HTMLElement | SVGElement, dataKey: string): string source
import {elemDataValue} from 'lib/dom.js'
Returns the value of the elements data attribute if it exists If the element is null/undefined or does not have data attributes null is returned.
Params:
Name | Type | Attribute | Description |
elem | HTMLElement | SVGElement | The element that should have the data attribute |
|
dataKey | string | The name of the data value to be retrieved |
public elemDataValueEqs(elem: HTMLElement | SVGElement, dataKey: *, dataValue: *): boolean source
import {elemDataValueEqs} from 'lib/dom.js'
Returns T/F indicating if the element has data attribute equal to the supplied value
Params:
Name | Type | Attribute | Description |
elem | HTMLElement | SVGElement | The element that should have the data attribute |
|
dataKey | * | The name of the data value to be retrieved |
|
dataValue | * | The expected value of the elements data attribute |
public elemHasChildren(elem: Element): boolean source
import {elemHasChildren} from 'lib/dom.js'
Returns T/F indicating if the supplied element has children. If the supplied element is null/undefined false is returned.
Params:
Name | Type | Attribute | Description |
elem | Element | The element to be checked for children |
public elemHasSibling(elem: SomeElement): boolean source
import {elemHasSibling} from 'lib/dom.js'
Returns T/F indicating if the supplied element has an sibling element
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
public elemHasZeroBoundingRect(elem: SomeElement): boolean source
import {elemHasZeroBoundingRect} from 'lib/dom.js'
Determines if the supplied elements bounding client rect's x,y,width,height,top,left properties all equal zero. Note this function returns true if the element is null/undefined;
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to be tested |
public elemInnerText(elem: SomeElement, trim: boolean): string source
import {elemInnerText} from 'lib/dom.js'
Returns the supplied elements innerText
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
|
trim | boolean |
|
Should the innerText be trimmed |
public elemInnerTextEqs(elem: SomeElement, shouldEqual: string, trim: boolean): boolean source
import {elemInnerTextEqs} from 'lib/dom.js'
Returns T/F if the supplied elements innerText equals the supplied string case sensitive
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
shouldEqual | string | The string the elements inner text should equal |
|
trim | boolean |
|
Should the innerText be trimmed before comparison |
public elemInnerTextEqsInsensitive(elem: SomeElement, shouldEqual: string, trim: boolean): boolean source
import {elemInnerTextEqsInsensitive} from 'lib/dom.js'
Returns T/F if the supplied elements innerText equals the supplied string case in-sensitive
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
shouldEqual | string | ||
trim | boolean |
|
public elemInnerTextEqsOneOf(elem: SomeElement, shouldEquals: ...string): boolean source
import {elemInnerTextEqsOneOf} from 'lib/dom.js'
Returns T/F if the supplied elements innerText equals one of the supplied string case sensitive
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
shouldEquals | ...string |
public elemInnerTextMatchesRegex(elem: SomeElement, regex: RegExp): boolean source
import {elemInnerTextMatchesRegex} from 'lib/dom.js'
Returns T/F if the supplied elements innerText matches the supplied regex
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
regex | RegExp |
public elemMatchesSelector(elem: SomeElement, selector: string): boolean source
import {elemMatchesSelector} from 'lib/dom.js'
Returns T/F indicating if the element matches the supplied selector
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
selector | string |
public elemOffsetTopZero(elem: SomeElement): boolean source
import {elemOffsetTopZero} from 'lib/dom.js'
Returns true if the supplied elements offsetTop === 0
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to check its offsetTop |
public elemTextContent(elem: SomeElement): string source
import {elemTextContent} from 'lib/dom.js'
Returns the textContent of the supplied element
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
public elementTextContains(elem: SomeElement, needle: string, caseInsensitive: boolean): boolean source
import {elementTextContains} from 'lib/dom.js'
Returns T/F indicating if the supplied element's textContents contains the supplied string
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
needle | string | The string that the elements textContents should contain |
|
caseInsensitive | boolean |
|
Should the compairison be case insensitive |
public elementTextEndsWith(elem: SomeElement, end: string): boolean source
import {elementTextEndsWith} from 'lib/dom.js'
Returns T/F indicating if the supplied element's textContent ends with the supplied string
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
end | string | The string the element's textContent should end with |
public elementTextEqs(elem: SomeElement, shouldEqual: string, caseInsensitive: boolean): boolean source
import {elementTextEqs} from 'lib/dom.js'
Returns T/F indicating if the supplied element's textContents equals the supplied string
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
shouldEqual | string | The string that the elements textContents should be equal to |
|
caseInsensitive | boolean |
|
Should the compairison be case insensitive |
public elementTextStartsWith(elem: SomeElement, start: string): boolean source
import {elementTextStartsWith} from 'lib/dom.js'
Returns T/F indicating if the supplied element's textContent starts with the supplied string
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
start | string | The string the element's textContent should start with |
public elementTextStartsWithAndEndsWith(elem: SomeElement, start: string, end: string): boolean source
import {elementTextStartsWithAndEndsWith} from 'lib/dom.js'
Returns T/F indicating if the supplied element' textContent starts and ends with the supplied start and end strings
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
start | string | The string the element's textContent should start with |
|
end | string | The string the element's textContent should end with |
public elementsNameEquals(elem: SomeElement, name: string): boolean source
import {elementsNameEquals} from 'lib/dom.js'
Returns T/F indicating if the elements name (localName) is equal to the supplied name
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to check if its name equals the supplied name |
|
name | string | The name of the desired element |
public extractProps(object: Object, props: ...string): Object source
import {extractProps} from 'lib/general.js'
Returns a new object with the properties of the object on the new object
public filteredQs(selector: string, filterFn: function(elem: SomeElement): boolean, context: SomeElement | Document): SomeElement source
import {filteredQs} from 'lib/dom.js'
Utility function for (document||element).querySelector(selector)
Params:
Name | Type | Attribute | Description |
selector | string | the selector to be use |
|
filterFn | function(elem: SomeElement): boolean | ||
context | SomeElement | Document |
|
element to use rather than document for the querySelector call |
public async findAllMediaElementsAndPlay(cntx: Document | Element): Promise<boolean> source
import {findAllMediaElementsAndPlay} from 'lib/media.js'
Calls the play function on all audio and video elements found in the document. If context is supplied, the selection of audio and video elements is done from the supplied context.
Params:
Name | Type | Attribute | Description |
cntx | Document | Element |
|
Optional element to use rather than the current JS context's document object |
public findChildWithKey(reactInstance: Object, key: string): Object source
import {findChildWithKey} from 'lib/reactUtils.js'
Walks the children of a react component to find the one that has the supplied key
public findDirectChildElement(parentElement: SomeElement, predicate: function(elem: SomeElement): boolean): SomeElement source
import {findDirectChildElement} from 'lib/dom.js'
Applies the supplied predicate
to every child element of the supplied
parent element and returns the element that the predicate
returns true for
otherwise returns null.
If the parent element is null then null is returned.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's child element will be searched |
|
predicate | function(elem: SomeElement): boolean | The predicate function used to select a child |
public findReduxStore(startingComponent: Object): Object source
import {findReduxStore} from 'lib/reactUtils.js'
Attempts the find the redux store from the supplied component
Params:
Name | Type | Attribute | Description |
startingComponent | Object |
public findTag(xpg: function(query: string, node: ?Node): Node[], tag: string, predicate: function(elem: SomeElement): boolean, cntx: Document | SomeElement): SomeElement source
import {findTag} from 'lib/dom.js'
Attempts to find a tag using the supplied function that accepts an xpath query and an optional starting element and returns the element the supplied predicate function returns a truthy value for
Params:
Name | Type | Attribute | Description |
xpg | function(query: string, node: ?Node): Node[] | xpath execution function |
|
tag | string | The tag to be found |
|
predicate | function(elem: SomeElement): boolean | Element selecting predicate function |
|
cntx | Document | SomeElement |
|
Optional starting element, defaults to |
public fireEventOn(elem: Element, event: Event) source
import {fireEventOn} from 'lib/events.js'
Fires the supplied event on the supplied element
public fireMouseEventsOnElement(config: FireMouseEventsOnOptions) source
import {fireMouseEventsOnElement} from 'lib/events.js'
Creates mouse events and fires them in order configured using the supplied options
Params:
Name | Type | Attribute | Description |
config | FireMouseEventsOnOptions |
public firstChildElemOfParent(elem: SomeElement): SomeElement source
import {firstChildElemOfParent} from 'lib/dom.js'
Returns the first child element of the supplied elements parent element. If the supplied element or the elements parent is null/undefined null is returned
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element who's parents first child is desired |
public firstChildElementOf(elem: SomeElement): SomeElement source
import {firstChildElementOf} from 'lib/dom.js'
Returns the supplied elements first element child. If the element is null null is returned
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element who's first child is desired |
public firstChildElementOfSelector(selector: string, cntx: Document | SomeElement): SomeElement source
import {firstChildElementOfSelector} from 'lib/dom.js'
Returns the first child element of the element matching the supplied selector
Params:
Name | Type | Attribute | Description |
selector | string | The selector to match the parent element of the desired child |
|
cntx | Document | SomeElement |
|
Optional starting element, defaults to |
public getElemSibling(elem: SomeElement): SomeElement source
import {getElemSibling} from 'lib/dom.js'
Returns the supplied elements next element sibling
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to receive its sibling |
public getElemSiblingAndRemoveElem(elem: SomeElement): SomeElement source
import {getElemSiblingAndRemoveElem} from 'lib/dom.js'
Returns the supplied elements next element sibling and removes the supplied element
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to receive its sibling |
public getElementClientPageCenter(element: SomeElement, options: {floor: boolean}): {clientY: number, clientX: number, pageY: number, pageX: number} source
import {getElementClientPageCenter} from 'lib/dom.js'
Get the center of the passed DOM element
Params:
Name | Type | Attribute | Description |
element | SomeElement | ||
options | {floor: boolean} |
|
public getElementClientPagePosition(element: SomeElement, options: Object): {clientY: number, clientX: number, pageY: number, pageX: number} source
import {getElementClientPagePosition} from 'lib/dom.js'
Get the position of the passed DOM element
Params:
Name | Type | Attribute | Description |
element | SomeElement | ||
options | Object |
public getElementPositionWidthHeight(element: Element, doc: Document): {y: number, pageY: number, x: number, pageX: number, w: number, h: number} source
import {getElementPositionWidthHeight} from 'lib/dom.js'
Helper function to get the actual x and y position, page x and y position (scroll) and the height, width of a given element
Params:
Name | Type | Attribute | Description |
element | Element | ||
doc | Document |
|
public getElemsParentsSibling(elem: SomeElement): SomeElement source
import {getElemsParentsSibling} from 'lib/dom.js'
Returns the next element sibling of the parent element of the supplied element
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to receive its sibling |
public getInternalRootOnElem(elem: HTMLElement | Element | Node): Object source
import {getInternalRootOnElem} from 'lib/reactUtils.js'
Returns the internal root object added by react on the supplied element.
Property _internalRoot
public getNthParentElement(elem: SomeElement, nth: number): SomeElement source
import {getNthParentElement} from 'lib/dom.js'
Returns the Nth parent element of the supplied element (indexing assumes start is 1)
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to retrieve the nth parent element of |
|
nth | number | The number of the nth parent |
public getReactRootContainer(elem: HTMLElement | Element | Node): Object source
import {getReactRootContainer} from 'lib/reactUtils.js'
Returns the root container object added by react
public getReactRootHostElem(alternativeId: string): HTMLElement source
import {getReactRootHostElem} from 'lib/reactUtils.js'
Returns the root host element of an react application (id = react-root)
Params:
Name | Type | Attribute | Description |
alternativeId | string |
|
An alternative id to use rather than the default |
Return:
HTMLElement (nullable: true) |
public getViaPath(obj: *, pathItems: *): * source
import {getViaPath} from 'lib/general.js'
Retrieves the property of an object, or item in array at index, based on the supplied path.
Params:
Name | Type | Attribute | Description |
obj | * | An object |
|
pathItems | * |
Return:
* |
Example:
const obj = { a: { b: { c: [1, 2, 3] } } }
const two = getViaPath(obj, 'a', 'b', 'c', 1); // two == 2
public globalWithPropsExist(global: string, props: ...string): boolean source
import {globalWithPropsExist} from 'lib/general.js'
Returns T/F if an global property (on window) exists and has
all properties. The existence check is obj[prop] != null
public hasAnyClass(elem: SomeElement, classes: ...string): boolean source
import {hasAnyClass} from 'lib/dom.js'
Tests to see if the supplied element has any of the supplied css classes
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element to be tested if it has any of the classes |
classes | ...string | The classes the element can have |
public hasClass(elem: SomeElement, clazz: string): boolean source
import {hasClass} from 'lib/dom.js'
Tests to see if the supplied element has a css class
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element to be tested if it has the class |
clazz | string | The classname |
public hasClasses(elem: SomeElement, classes: ...string): boolean source
import {hasClasses} from 'lib/dom.js'
Tests to see if the supplied element has the supplied css classes
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element to be tested if it has the classes |
classes | ...string | The classes the element must have |
public id(eid: string, context: SomeElement | Document): SomeElement source
import {id} from 'lib/dom.js'
Utility function for document.getElementById(id)
Params:
Name | Type | Attribute | Description |
eid | string | The id of the element to get |
|
context | SomeElement | Document |
|
Optional document element to use rather than the current JS context's |
public idExists(eid: string, cntx: Document): boolean source
import {idExists} from 'lib/dom.js'
Determines if the element the supplied id identifies exists
Params:
Name | Type | Attribute | Description |
eid | string | The id of the element |
|
cntx | Document |
|
Optional document object to use rather than the current JS context's document object |
public initRunnableBehavior(init: BehaviorRunnerInitOpts): BehaviorRunner source
import {initRunnableBehavior} from 'lib/behaviorRunner.js'
Performs the setup required for integration with Webrecorders automation system Adds as propeties to the supplied window object
- $WBBehaviorStepIter$: the supplied
behaviorStepIterator
- $WBBehaviorRunner$: the instance of the class that wraps the behaviors actions
- $WRIteratorHandler$: a function that initiates a behaviors action
Params:
Name | Type | Attribute | Description |
init | BehaviorRunnerInitOpts | Object used to initialize the behavior for running |
public innerTextOfSelected(selector: string, cntx: SomeElement | Document): string source
import {innerTextOfSelected} from 'lib/dom.js'
Returns the inner text of the element the supplied selectors matches
Params:
Name | Type | Attribute | Description |
selector | string | the selector to be use |
|
cntx | SomeElement | Document |
|
element to use rather than document for the querySelector call |
public isAlpha(str: string): boolean source
import {isAlpha} from 'lib/strings.js'
Returns T/F indicating if the supplied string is only alpha characters
Params:
Name | Type | Attribute | Description |
str | string |
|
public isAlphaNumeric(str: string): boolean source
import {isAlphaNumeric} from 'lib/strings.js'
Returns T/F indicating if the supplied string is only alpha numeric characters
Params:
Name | Type | Attribute | Description |
str | string |
|
public isClasslessElem(elem: SomeElement): boolean source
import {isClasslessElem} from 'lib/dom.js'
Returns T/F indicating if the supplied element has not CSS classes
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
public isElemVisible(elem: SomeElement): boolean source
import {isElemVisible} from 'lib/dom.js'
Returns T/F indicating if the supplied element is visible.
If the supplied element is falsy the return value is false.
The test checks the computed style of the supplied element to determine if it's css display property is not null and the visibility of the element is visible.
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
public isEmptyString(str: string): boolean source
import {isEmptyString} from 'lib/strings.js'
Returns T/F indicating if the supplied string is truly an empty string
Params:
Name | Type | Attribute | Description |
str | string |
|
public isFunction(obj: *): boolean source
import {isFunction} from 'lib/general.js'
Returns T/F indicating if the supplied arument is a function
Params:
Name | Type | Attribute | Description |
obj | * |
public isGenerator(obj: *): boolean source
import {isGenerator} from 'lib/general.js'
Returns T/F indicating if the supplied object is a generator or async generator
Params:
Name | Type | Attribute | Description |
obj | * |
public isLower(str: string): boolean source
import {isLower} from 'lib/strings.js'
Returns T/F indicating if the supplied string is only lowercase alpha characters
Params:
Name | Type | Attribute | Description |
str | string |
public isNumeric(str: string): boolean source
import {isNumeric} from 'lib/strings.js'
Returns T/F indicating if the supplied string only contains numeric characters
Params:
Name | Type | Attribute | Description |
str | string |
|
public isPromise(obj: *): boolean source
import {isPromise} from 'lib/general.js'
Returns T/F indicating if the supplied object is a Promise or Promise like
Params:
Name | Type | Attribute | Description |
obj | * |
public isUpper(str: string): boolean source
import {isUpper} from 'lib/strings.js'
Returns T/F indicating if the supplied string is only uppercase alpha characters
Params:
Name | Type | Attribute | Description |
str | string |
|
public lastChildElementOf(elem: SomeElement): SomeElement source
import {lastChildElementOf} from 'lib/dom.js'
Returns the last child element of the supplied element
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element who's last child element is desired |
public lastChildElementOfSelector(selector: string, cntx: Document | SomeElement): SomeElement source
import {lastChildElementOfSelector} from 'lib/dom.js'
Returns the last child element of the element the selector selects
Params:
Name | Type | Attribute | Description |
selector | string | The selector to be used to select the element who's last child element is desired |
|
cntx | Document | SomeElement |
|
Optional starting element, defaults to |
public locationContains(something: string): boolean source
import {locationContains} from 'lib/browser.js'
Determines if window.location.href
contains
the supplied value as a substring.
Params:
Name | Type | Attribute | Description |
something | string | The value to determine if
it is a substring of |
public locationEquals(someLocation: string): boolean source
import {locationEquals} from 'lib/browser.js'
Determines the strict equality of the string
to the value of window.location.href
Params:
Name | Type | Attribute | Description |
someLocation | string | The expect location.href value |
public async * mapAsyncIterator(iterator: AsyncIterableIterator<*>, mapper: function(arg: *): *): AsyncIterableIterator<*> source
import {mapAsyncIterator} from 'lib/general.js'
Like map for arrays but over async-iterators
Params:
Name | Type | Attribute | Description |
iterator | AsyncIterableIterator<*> | The iterator to have a mapping function applied over |
|
mapper | function(arg: *): * | The mapping function |
Return:
AsyncIterableIterator<*> |
public markElemAsVisited(elem: SomeElement, marker: string) source
import {markElemAsVisited} from 'lib/dom.js'
Marks the supplied element as visited by adding the marker to its classList.
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element to mark as visited |
|
marker | string |
|
Optional marker to use
defaults to |
public maybePolyfillXPG(cliXPG: function(...args: *): Array<SomeElement>): function(...args: *): Array<SomeElement> source
import {maybePolyfillXPG} from 'lib/dom.js'
Ensures that if the value of the chrome console utility $x is not the actual utility (jquery is on the page) the returned function behaves exactly like it.
Params:
Name | Type | Attribute | Description |
cliXPG | function(...args: *): Array<SomeElement> |
public maybeRemoveElem(selector: string, context: SomeElement | Document): boolean source
import {maybeRemoveElem} from 'lib/dom.js'
Removes the element selected by the supplied querySelector, if it exits, returning true to indicate the element was removed and false otherwise
Params:
Name | Type | Attribute | Description |
selector | string | the selector to be use |
|
context | SomeElement | Document |
|
element to use rather than document for the querySelector call |
public maybeRemoveElemById(eid: string, context: SomeElement | Document): boolean source
import {maybeRemoveElemById} from 'lib/dom.js'
Removes the element with the supplied id, if it exits, returning true to indicate the element was removed and false otherwise
Params:
Name | Type | Attribute | Description |
eid | string | The id of the element to remove |
|
context | SomeElement | Document |
|
Optional document element to use rather than the current JS context's |
public async * noExceptGeneratorWrap(generator: AsyncIterableIterator<*>|IterableIterator<*>, returnLast: boolean): AsyncIterableIterator<*> source
import {noExceptGeneratorWrap} from 'lib/general.js'
Wraps the supplied generator in a try catch and re-yields its values generator. If the wrapped generator throws an exception the wrapping generator ends.
Params:
Name | Type | Attribute | Description |
generator | AsyncIterableIterator<*>|IterableIterator<*> | The generator to be wrapped |
|
returnLast | boolean |
|
Should the last value of the supplied generator be returned |
Return:
AsyncIterableIterator<*> |
public async noExceptPlayMediaElement(mediaElement: HTMLMediaElement, playThrough: boolean): Promise<boolean> source
import {noExceptPlayMediaElement} from 'lib/media.js'
Calls the play function of the supplied element catching the exception thrown if any was thrown. Returns true indicating call to play was successful otherwise false
Params:
Name | Type | Attribute | Description |
mediaElement | HTMLMediaElement | ||
playThrough | boolean |
|
public nodesNameEquals(node: SomeElement, name: string): boolean source
import {nodesNameEquals} from 'lib/dom.js'
Returns T/F indicating if the nodes name (nodeName) is equal to the supplied name
Params:
Name | Type | Attribute | Description |
node | SomeElement | The node to check if its name equals the supplied name |
|
name | string | The name of the desired Node |
public nthChildElementOf(elem: SomeElement | Document, nth: number): SomeElement source
import {nthChildElementOf} from 'lib/dom.js'
Returns the Nth child element of the supplied element (indexing assumes start is 1)
Params:
Name | Type | Attribute | Description |
elem | SomeElement | Document | The element to retrieve the nth child element of |
|
nth | number | The number of the nth child element |
public nthChildNodeOf(elem: SomeElement | Document, nth: number): SomeElement source
import {nthChildNodeOf} from 'lib/dom.js'
Returns the Nth child node of the supplied element (indexing assumes start is 1)
Params:
Name | Type | Attribute | Description |
elem | SomeElement | Document | The element to retrieve the nth child of |
|
nth | number | The number of the nth child |
public nthPreviousSibling(elem: SomeElement, nth: number): SomeElement source
import {nthPreviousSibling} from 'lib/dom.js'
Returns the nth previous sibling of the supplied element if it is not null/undefined or the supplied element is not null/undefined
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element who's nth previous sibling is desired |
nth | number | The nth previous sibling |
public numElemChildren(elem: SomeElement): number source
import {numElemChildren} from 'lib/dom.js'
Returns the number of child elements the supplied element has if it is not null/undefined otherwise -1
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element who's child element count is deired |
public objectHasProps(obj: Object, props: ...string): boolean source
import {objectHasProps} from 'lib/general.js'
Returns T/F if the supplied object has all of the supplied properties.
The existence check is obj[prop] != null
public objectInstanceOf(obj: Object, shouldBeInstanceOfThis: Object): boolean source
import {objectInstanceOf} from 'lib/general.js'
Returns T/F indicating if the supplied object is an instance of some class. If the object to be tested is falsy false is returned otherwise the results of the instanceof check.
public partial(fn: function, a1: *, a2: *, a3: *, a4: *, a5: *, aN: ...*): function(...args: *): * source
import {partial} from 'lib/general.js'
Creates and returns a partially applied function with args being applied left to right
Params:
Name | Type | Attribute | Description |
fn | function | The function to partially apply arguments to |
|
a1 | * |
|
1st arg |
a2 | * |
|
2nd arg |
a3 | * |
|
3rd arg |
a4 | * |
|
4th arg |
a5 | * |
|
5th arg |
aN | ...* |
|
The remaining arguments to be partially applied |
public partialRight(fn: function, a1: *, a2: *, a3: *, a4: *, a5: *, aN: ...*): function(...args: *): * source
import {partialRight} from 'lib/general.js'
Creates and returns a partially applied function with args being applied right to left
Params:
Name | Type | Attribute | Description |
fn | function | The function to partially apply arguments to |
|
a1 | * |
|
1st nth arg |
a2 | * |
|
2nd nth arg |
a3 | * |
|
3rd nth arg |
a4 | * |
|
4th nth arg |
a5 | * |
|
5th nth arg |
aN | ...* |
|
The remaining arguments to be partially applied |
public promiseResolveReject(): {resolve: function, reject: function, promise: Promise<*>} source
import {promiseResolveReject} from 'lib/general.js'
Creates a Promise that is resolvable externally returning an object that exposes the promise itself and the resolve and reject functions passed as arguments to the executor function
public qs(selector: string, context: SomeElement | Document): SomeElement source
import {qs} from 'lib/dom.js'
Utility function for (document||element).querySelector(selector)
Params:
Name | Type | Attribute | Description |
selector | string | the selector to be use |
|
context | SomeElement | Document |
|
element to use rather than document for the querySelector call |
public qsOneOf(options: {selectors: Array<string>, context: *}): SomeElement source
import {qsOneOf} from 'lib/dom.js'
Returns the results of querySelector using one of the supplied selectors one if one of the selectors yields results otherwise null/undefined
public qsa(selector: string, context: SomeElement | Document): NodeList<SomeElement> source
import {qsa} from 'lib/dom.js'
Utility function for document.querySelectorAll(selector)
Params:
Name | Type | Attribute | Description |
selector | string | the selector to be use |
|
context | SomeElement | Document |
|
element to use rather than document for the querySelector call |
public qsaOneOf(options: {selectors: Array<string>, context: *}): NodeList<SomeElement> source
import {qsaOneOf} from 'lib/dom.js'
Returns the results of querySelectorAll using one of the supplied selectors if one of the selectors yields results otherwise null/undefined
public reactInstanceFromDOMElem(elem: HTMLElement | Element | Node): Object source
import {reactInstanceFromDOMElem} from 'lib/reactUtils.js'
Returns the react instance object that lives on the live element
public reactInstancesFromElements(elems: Array<Node|HTMLElement|Element>, selectingFn: function(key: string): boolean): Array<{node: HTMLElement|Element|Node, reactInstance: Object}> source
import {reactInstancesFromElements} from 'lib/reactUtils.js'
Converts the supplied array of elements into an array of objects each with property node (the live dom element) and reactInstance (the live react component). An optional selection function can be supplied that receives the rendered components key and returns T/F to indicate if the component and element is to be selected
public removeClass(elem: SomeElement, clazz: string) source
import {removeClass} from 'lib/dom.js'
Removes a CSS classname to the supplied element
Params:
Name | Type | Attribute | Description |
elem | SomeElement |
|
The element to remove the classname to |
clazz | string | The classname to be removed |
public * repeatedXpathQueryIterator(query: string, cntx: *, generateMoreElements: function(): void): IterableIterator<SomeElement> source
import {repeatedXpathQueryIterator} from 'lib/dom.js'
Repeatably performs the supplied xpath query yielding the results of the each query. If an empty result set is encountered and generateMoreElements function was supplied it is called and the query repeated. If the second query try yields another empty set the iterator ends
Params:
Name | Type | Attribute | Description |
query | string | The xpath query to be repeated until it returns no more elements |
|
cntx | * |
|
Optional element to execute the xpath query from (defaults to document) |
generateMoreElements | function(): void |
|
Optional function used to generate more elements that may match the supplied xpath |
public async * repeatedXpathQueryIteratorAsync(query: string, cntx: *, generateMoreElements: function(): *): AsyncIterableIterator<SomeElement> source
import {repeatedXpathQueryIteratorAsync} from 'lib/dom.js'
Repeatably performs the supplied xpath query yielding the results of the each query. If an empty result set is encountered and generateMoreElements function was supplied it is called and the query repeated. If the second query try yields another empty set the iterator ends
Params:
Name | Type | Attribute | Description |
query | string | The xpath query to be repeated until it returns no more elements |
|
cntx | * |
|
Optional element to execute the xpath query from (defaults to document) |
generateMoreElements | function(): * |
|
Optional function used to generate more elements that may match the supplied xpath |
public resolveWhenBehaviorUnPaused(): Promise<any> source
import {resolveWhenBehaviorUnPaused} from 'lib/delays.js'
Returns a Promise that resolves once the behavior has been un-paused
public scrollAllIntoViewAndClick(elems: Array<HTMLElement>): number source
import {scrollAllIntoViewAndClick} from 'lib/clicks.js'
Scrolls into view and clicks all the elements present in the supplied array.
Params:
Name | Type | Attribute | Description |
elems | Array<HTMLElement> | The array of elements to be scrolled into view and clicked |
public async scrollAllIntoViewAndClickWithDelay(elems: Array<HTMLElement|Element|Node>, delayTime: number): Promise<void> source
import {scrollAllIntoViewAndClickWithDelay} from 'lib/clicks.js'
Scrolls into view and clicks all the elements present in the supplied array waiting for the supplied delay time after each click of an element in the array.
public scrollDownByElemHeight(elem: Element | HTMLElement | Node): void source
import {scrollDownByElemHeight} from 'lib/scrolls.js'
Scrolls down by the elements height
Return:
void |
public scrollDownByElemHeightWithDelay(elem: Element | HTMLElement | Node, delayTime: number): Promise<void> source
import {scrollDownByElemHeightWithDelay} from 'lib/scrolls.js'
Scrolls down by supplied elements height and then waits for the supplied delay time.
public scrollIntoView(elem: Element, opts: Object): void source
import {scrollIntoView} from 'lib/scrolls.js'
Scrolls the supplied element into view.
Scroll behavior:
- behavior: smooth
- block: center
- inline: center
Return:
void |
public scrollIntoViewAndClick(elem: HTMLElement | Element): boolean source
import {scrollIntoViewAndClick} from 'lib/clicks.js'
Scrolls the supplied element into view and clicks it if the element is non-null/undefined
Params:
Name | Type | Attribute | Description |
elem | HTMLElement | Element | The element to be scrolled into view and clicked. |
public scrollIntoViewAndClickWithDelay(elem: HTMLElement | Element, delayTime: number): Promise<boolean> source
import {scrollIntoViewAndClickWithDelay} from 'lib/clicks.js'
Scrolls the supplied element into view and clicks it if the element is non-null/undefined and waits for the specified delay time
public scrollIntoViewAndWaitFor(elem: Element | HTMLElement | Node, predicate: function(): boolean, options: {wait: ?WaitForOptions, scrollBehavior: ?Object}): Promise<{predicate: boolean, maxExceeded: boolean}>{predicate:> source
import {scrollIntoViewAndWaitFor} from 'lib/scrolls.js'
Scrolls the supplied element into view and then waits for the supplied predicate function to return true
Scroll behavior:
- behavior: smooth
- block: center
- inline: center
Params:
Name | Type | Attribute | Description |
elem | Element | HTMLElement | Node | The element to be scrolled into view with delay |
|
predicate | function(): boolean | Function returning T/F to indicate when the condition waited for has been satisfied |
|
options | {wait: ?WaitForOptions, scrollBehavior: ?Object} |
|
Options controlling the scroll behavior and how the wait will happen |
public scrollIntoViewWithDelay(elem: Element | HTMLElement | Node, delayTime: number): Promise<void> source
import {scrollIntoViewWithDelay} from 'lib/scrolls.js'
Scrolls the supplied element into view, afterwards waits for the specified delay time
Scroll behavior:
- behavior: smooth
- block: center
- inline: center
public scrollToElemOffset(elem: Element | HTMLElement | Node, behavior: string): void source
import {scrollToElemOffset} from 'lib/scrolls.js'
Scrolls the window by the supplied elements offsetTop. If the elements offsetTop is zero then scrollIntoView is used
Return:
void |
public scrollToElemOffsetWithDelay(elem: Element | HTMLElement | Node, delayTime: number): Promise<void> source
import {scrollToElemOffsetWithDelay} from 'lib/scrolls.js'
Scrolls the window by the supplied elements offsetTop. If the elements offsetTop is zero then scrollIntoView is used
public scrollWindowBy(x: number, y: number) source
import {scrollWindowBy} from 'lib/scrolls.js'
Scrolls the window by the supplied x and y amount
public scrollWindowByWithDelay(x: number, y: number, delayTime: number): Promise<void> source
import {scrollWindowByWithDelay} from 'lib/scrolls.js'
Scrolls the window by the supplied x and y amount
public scrollWindowDownBy(amount: number) source
import {scrollWindowDownBy} from 'lib/scrolls.js'
Scrolls the window down by the supplied amount
Params:
Name | Type | Attribute | Description |
amount | number | Amount to scroll the down by |
public scrollWindowDownByWithDelay(amount: number, delayTime: number): Promise<void> source
import {scrollWindowDownByWithDelay} from 'lib/scrolls.js'
Scrolls the window down by the supplied amount
public secondsToDelayAmount(n: number): number source
import {secondsToDelayAmount} from 'lib/delays.js'
Converts the supplied n number of seconds into milliseconds which is required for setTimeout and setInterval
Params:
Name | Type | Attribute | Description |
n | number | The number of seconds to be delayed |
public selectAllAndClick(selector: string, context: Element): boolean source
import {selectAllAndClick} from 'lib/clicks.js'
Selects all elements that match the supplied selector and clicks them returning T/F indicating if a click happened on any selected element
public async selectAllAndClickWithDelay(opts: {selector: string, cntx: *, delayTime: *}): boolean source
import {selectAllAndClickWithDelay} from 'lib/clicks.js'
Selects all elements that match the supplied selector and clicks them returning T/F indicating if a click happened on any selected element
Params:
Name | Type | Attribute | Description |
opts | {selector: string, cntx: *, delayTime: *} |
public selectAndPlay(selector: string, cntx: Document | Element): Promise<boolean> source
import {selectAndPlay} from 'lib/media.js'
Calls the play method of the element returned by the querySelector
public selectClickAndWaitFor(selector: string, predicate: function(): boolean, selectFrom: HTMLElement | Document): Promise<{predicate: boolean, maxExceeded: boolean, clicked: boolean}>{predicate:> source
import {selectClickAndWaitFor} from 'lib/clicks.js'
Clicks the element returned by calling querySelector using the selector on document or the supplied element (selectFrom) and then waits for the supplied predicate function to return true
public selectElemAndClick(selector: string, cntx: *): boolean source
import {selectElemAndClick} from 'lib/clicks.js'
Clicks the element from executing document.querySelector using the supplied selector
Params:
Name | Type | Attribute | Description |
selector | string | the css selector to use |
|
cntx | * |
|
element to use rather than document for the querySelector call |
public selectElemAndClickWithDelay(selector: string, delayTime: number): Promise<boolean> source
import {selectElemAndClickWithDelay} from 'lib/clicks.js'
Clicks the element from executing document.querySelector using the supplied selector and waiting the specified delay time after clicking
public selectElemFromAndClick(selectFrom: Element | Node | HTMLElement, selector: string): boolean source
import {selectElemFromAndClick} from 'lib/clicks.js'
Clicks the element from executing querySelector using the supplied selector using the supplied element
public selectElemFromAndClickWithDelay(selectFrom: Element | Node | HTMLElement, selector: string, delayTime: number): Promise<boolean> source
import {selectElemFromAndClickWithDelay} from 'lib/clicks.js'
Clicks the element from executing querySelector using the supplied selector from the supplied element and waiting the specified delay time after clicking
public selectFromAndClickNTimes(selectFrom: Element, selector: string, n: number): number source
import {selectFromAndClickNTimes} from 'lib/clicks.js'
Clicks the element returned from result of calling querySelector using the supplied selector on the supplied element N number of times. Note that the evaluation of the querySelector is done all N times.
public async selectFromAndClickNTimesWithDelay(selectFrom: Element, selector: string, n: number, delayTime: number): Promise<number> source
import {selectFromAndClickNTimesWithDelay} from 'lib/clicks.js'
Clicks the element returned from result of calling querySelector using the supplied selector on the supplied element N number of times and waits for delay time afters each click. Note that the evaluation of the querySelector is done all N times.
Params:
Name | Type | Attribute | Description |
selectFrom | Element | The element to use to call querySelector(selector) on |
|
selector | string | the css selector to use |
|
n | number | How many times to click the element returned by performing selectFrom.querySelector(selector) |
|
delayTime | number |
|
How long is the delay |
public async selectFromAndClickUntilNullWithDelay(selectFrom: Element, selector: string, options: {delay: number, max: ?number}): Promise<number> source
import {selectFromAndClickUntilNullWithDelay} from 'lib/clicks.js'
Clicks the element returned from result of calling querySelector using the supplied selector on the supplied element until the results of the evaluting the selector returns null/undefined, waiting for delay time afters each click.
public selectIdAndPlay(eid: string, cntx: Document): Promise<boolean> source
import {selectIdAndPlay} from 'lib/media.js'
Calls the play method of the element returned by calling document.getElementById
Params:
Name | Type | Attribute | Description |
eid | string | The id of the media element |
|
cntx | Document |
|
Optional document object to use |
public selectScrollIntoViewAndClickSelectedWhileConnected(selector: string, options: SelectScrollIntoViewClickUntilNullOptions): void source
import {selectScrollIntoViewAndClickSelectedWhileConnected} from 'lib/clicks.js'
Like selectFromAndClickUntilNullWithDelay but will stop selecting and clicking the selected element if the current reference becomes disconnected from the dom or the optional stopPredicate returns true. There is no dealy for delay you want selectScrollIntoViewAndClickWithDelayWhileSelectedConnected
Params:
Name | Type | Attribute | Description |
selector | string | The selector to be used to select the element |
|
options | SelectScrollIntoViewClickUntilNullOptions |
Return:
void |
public async selectScrollIntoViewAndClickWithDelayWhileSelectedConnected(selector: string, options: SelectScrollIntoViewClickUntilNullOptions): Promise<void> source
import {selectScrollIntoViewAndClickWithDelayWhileSelectedConnected} from 'lib/clicks.js'
Like selectFromAndClickUntilNullWithDelay but will stop selecting and clicking the selected element if the current reference becomes disconnected from the dom or the optional stopPredicate returns true.
Params:
Name | Type | Attribute | Description |
selector | string | The selector to be used to select the element |
|
options | SelectScrollIntoViewClickUntilNullOptions |
|
Additional configuration options |
public selectedNextElementSibling(selector: string, context: SomeElement | Document): SomeElement source
import {selectedNextElementSibling} from 'lib/dom.js'
Returns the next element sibling of the supplied selector IFF the selector returns a results and the next element sibling exists otherwise null/undefined
Params:
Name | Type | Attribute | Description |
selector | string | The selector for the element who's next sibling is to be returned |
|
context | SomeElement | Document |
|
element to use rather than document for the querySelector call |
public selectorExists(selector: string, cntx: Document | SomeElement): boolean source
import {selectorExists} from 'lib/dom.js'
Determines if the element the supplied selector selects exists
Params:
Name | Type | Attribute | Description |
selector | string | The querySelector to use for testing if the element it selects exists |
|
cntx | Document | SomeElement |
|
Optional element to use rather than the current JS context's document object |
public sendAutoFetchWorkerURLs(urls: Array<string>) source
import {sendAutoFetchWorkerURLs} from 'lib/general.js'
Sends the supplied array of URLs to the backing pywb/webrecorder auto-fetch worker if it exists
public setIntervalP(callback: *, timeout: *): number source
import {setIntervalP} from 'lib/delays.js'
Polls the supplied function at the timeout rate only if the behavior is not paused
Params:
Name | Type | Attribute | Description |
callback | * | ||
timeout | * |
public setTimeoutP(callback: *, timeout: *): number source
import {setTimeoutP} from 'lib/delays.js'
Like setTimeout except that the timeout respects the pause state of the behavior
Params:
Name | Type | Attribute | Description |
callback | * | ||
timeout | * |
public smoothScrollWindowBy(x: number, y: number) source
import {smoothScrollWindowBy} from 'lib/scrolls.js'
Scrolls the window by the supplied x and y amount smoothly
public smoothScrollWindowDownBy(amount: number) source
import {smoothScrollWindowDownBy} from 'lib/scrolls.js'
Scrolls the window down by the supplied amount smoothly
Params:
Name | Type | Attribute | Description |
amount | number | Amount to scroll the down by |
public splitElemInnerText(elem: SomeElement, splitter: string | RegExp): Array<string> source
import {splitElemInnerText} from 'lib/dom.js'
Returns the results of splitting the supplied elements innerText using the supplied splitter
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
splitter | string | RegExp |
public splitElemTextContents(elem: SomeElement, splitter: string | RegExp): Array<string> source
import {splitElemTextContents} from 'lib/dom.js'
Returns the results of splitting the supplied elements textContent using the supplied splitter
Params:
Name | Type | Attribute | Description |
elem | SomeElement | ||
splitter | string | RegExp |
public stateWithMsgNoWait(msg: string, state: *): BehaviorState source
import {stateWithMsgNoWait} from 'lib/behaviorState.js'
Returns a behavior state object with the supplied msg indicating the behavior runner should not wait for network idle. The value returned should be yield'd to the behavior runner
Params:
Name | Type | Attribute | Description |
msg | string | A message from the behavior representing a description of the action just performed |
|
state | * |
|
Any additional information about the full state of the behavior |
public stateWithMsgWait(msg: string, state: *): BehaviorState source
import {stateWithMsgWait} from 'lib/behaviorState.js'
Returns a behavior state object with the supplied msg indicating the behavior runner should wait for network idle. The value returned should be yield'd to the behavior runner
Params:
Name | Type | Attribute | Description |
msg | string | A message from the behavior representing a description of the action just performed |
|
state | * |
|
Any additional information about the full state of the behavior |
public async stateWithMsgWaitFromAwaitable(awaitable: Promise<boolean>, msg: *, state: *): Promise<BehaviorState> source
import {stateWithMsgWaitFromAwaitable} from 'lib/behaviorState.js'
Returns a Promise that resolves to an behavior state object with the supplied msg with the wait value being set by the value resolved Promise. The value returned should be yield'd to the behavior runner
public stateWithMsgWaitFromFn(fn: function(): boolean, msg: *, state: *): BehaviorState source
import {stateWithMsgWaitFromFn} from 'lib/behaviorState.js'
Returns a behavior state object with the supplied msg with the wait value being set by the return value of the supplied function. The value returned should be yield'd to the behavior runner
public stringBetween(str: string, left: string, right: string): string source
import {stringBetween} from 'lib/strings.js'
Returns the string between the left and right string
public substringFromIndexOf(str: string, needle: string, opts: SubstringArgs): string source
import {substringFromIndexOf} from 'lib/strings.js'
Returns the substring from the index of the supplied needle
Params:
Name | Type | Attribute | Description |
str | string | ||
needle | string | The substring to be searched for |
|
opts | SubstringArgs |
|
public substringFromLastIndexOf(str: string, needle: string, opts: SubstringArgs): string source
import {substringFromLastIndexOf} from 'lib/strings.js'
Returns the substring from the last index of the supplied needle
Params:
Name | Type | Attribute | Description |
str | string | ||
needle | string | The substring to be searched for |
|
opts | SubstringArgs |
|
public titleCase(str: string): string source
import {titleCase} from 'lib/strings.js'
Attempts to convert the supplied string into title case
Params:
Name | Type | Attribute | Description |
str | string |
|
public toBoolean(str: string | boolean | number): boolean source
import {toBoolean} from 'lib/strings.js'
Attempts to convert the supplied string to boolean (true, yes, on, 1)
public toFloat(str: string, precision: number): number source
import {toFloat} from 'lib/strings.js'
Attempts to convert the supplied string to a float
public toInt(str: string, base: number): number source
import {toInt} from 'lib/strings.js'
Attempts to convert the supplied string to a integer
public async * traverseChildrenOf(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> source
import {traverseChildrenOf} from 'lib/traversals.js'
Applies a function to the children of the supplied parent element yielding the return value of the function.
When a child of the parent element does not have a next element sibling the generator ends.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's children are to be traversed |
|
fn | function(element: SomeElement, additionalArgs: *): * | The function to be applied to each child element |
|
additionalArgs | * |
|
Any additional arguments to be supplied to the function applied to each child element |
Return:
AsyncIterableIterator<*> |
public async * traverseChildrenOfCustom(opts: TraversalOpts): AsyncIterableIterator<*> source
import {traverseChildrenOfCustom} from 'lib/traversals.js'
Traverses the children of the supplied element applying the supplied function to each child and yielding the return value of the function.
If the loader option is true or shouldWait and or wait function(s) are supplied then the walk behaves as if the loader was set to true.
When operating in loader mode and a child of the parent element does not have a next element sibling, a wait for additional child elements to be added is done, if no custom wait function was supplied the wait happens for a maximum of 15 seconds. After the wait ends and if the current child element still does not have a next element sibling the generator ends.
When not operating in loader mode and the current child element does not have a next element sibling the traversal ends.
See the documentation for TraversalOpts for the customization options available.
Params:
Name | Type | Attribute | Description |
opts | TraversalOpts | Options for configuring the traversal |
Return:
AsyncIterableIterator<*> |
public async * traverseChildrenOfLoaderParent(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> source
import {traverseChildrenOfLoaderParent} from 'lib/traversals.js'
Applies a function to the children of the supplied parent element yielding the return value of the function.
When a child of the parent element does not have a next element sibling a wait for additional child elements to be added is done for a maximum of 15 seconds and if the current child element still does not have a next element sibling the generator ends.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's children are to be traversed |
|
fn | function(element: SomeElement, additionalArgs: *): * | The function to be applied to each child element |
|
additionalArgs | * |
|
Any additional arguments to be supplied to the function applied to each child element |
Return:
AsyncIterableIterator<*> |
public async * traverseChildrenOfLoaderParentGenFn(parentElement: SomeElement, genFn: function(): BoolOrPromiseBool, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> source
import {traverseChildrenOfLoaderParentGenFn} from 'lib/traversals.js'
Applies a function to the children of the supplied parent element yielding the return value of the function.
When a child of the parent element does not have a next element sibling, the supplied genFun is called and a wait for additional child elements to be added is done for a maximum of 15 seconds. After the wait ends and if the current child element still does not have a next element sibling the generator ends.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's children are to be traversed |
|
genFn | function(): BoolOrPromiseBool | Function used to generator more elements returning T/F indicating if a wait should be done |
|
fn | function(element: SomeElement, additionalArgs: *): * | The function to be applied to each child element |
|
additionalArgs | * |
|
Any additional arguments to be supplied to the function applied to each child element |
Return:
AsyncIterableIterator<*> |
public async * traverseChildrenOfLoaderParentRemovingPrevious(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> source
import {traverseChildrenOfLoaderParentRemovingPrevious} from 'lib/traversals.js'
Applies a function to the children of the supplied parent element yielding the return value of the function and then removing the previously considered child element from the DOM.
When a child of the parent element does not have a next element sibling a wait for additional child elements to be added is done for a maximum of 15 seconds and if the current child element still does not have a next element sibling the generator ends.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's children are to be traversed |
|
fn | function(element: SomeElement, additionalArgs: *): * | The function to be applied to each child element |
|
additionalArgs | * |
|
Any additional arguments to be supplied to the function applied to each child element |
Return:
AsyncIterableIterator<*> |
public async * traverseChildrenOfRemovingPrevious(parentElement: SomeElement, fn: function(element: SomeElement, additionalArgs: *): *, additionalArgs: *): AsyncIterableIterator<*> source
import {traverseChildrenOfRemovingPrevious} from 'lib/traversals.js'
Applies a function to the children of the supplied parent element yielding the return value of the function and then removing the previously considered child element from the DOM.
When a child of the parent element does not have a next element sibling the generator ends.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element who's children are to be traversed |
|
fn | function(element: SomeElement, additionalArgs: *): * | The function to be applied to each child element |
|
additionalArgs | * |
|
Any additional arguments to be supplied to the function applied to each child element |
Return:
AsyncIterableIterator<*> |
public uaThinksMediaElementCanPlayAllTheWay(mediaElement: HTMLMediaElement): Promise<void> source
import {uaThinksMediaElementCanPlayAllTheWay} from 'lib/media.js'
Returns a promise that resolves once the canplaythrough or error event is fired from the supplied media element
Params:
Name | Type | Attribute | Description |
mediaElement | HTMLMediaElement |
public uuidv4(): string source
import {uuidv4} from 'lib/general.js'
Creates and returns a valid uuid v4
public waitForAdditionalElemChildren(parentElement: SomeElement, options: WaitForOptions): Promise<WaitResult> source
import {waitForAdditionalElemChildren} from 'lib/delays.js'
Waits for the number children of the supplied parentElement
to become greater than the supplied parent elements currentChildCount
.
Configuration
If a max
is supplied (defaults to 15 seconds) the wait for additional children
to be added will not exceed the configured max
value unless max = -1
,
which in this case, the wait is infinite.
When a guard
function is supplied it is polled at value of pollRate
(defaults to 1 second), if and when it returns true the wait is considered
done regardless if the supplied parent element had additional children
added to it.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element |
|
options | WaitForOptions |
|
Options controlling the wait |
public waitForAdditionalElemChildrenMO(parentElement: SomeElement, options: GuardedWaitForOptions): Promise<WaitResult> source
import {waitForAdditionalElemChildrenMO} from 'lib/delays.js'
Waits for additional child elements to be added to the supplied parentElement using a mutation observer.
Configuration
If a max
is supplied (defaults to 15 seconds) the wait for additional children
to be added will not exceed the configured max
value unless max = -1
,
which in this case, the wait is infinite.
When a guard
function is supplied it is polled at value of pollRate
(defaults to 1 second), if and when it returns true the wait is considered
done regardless if the supplied parent element had additional children
added to it.
Params:
Name | Type | Attribute | Description |
parentElement | SomeElement | The parent element |
|
options | GuardedWaitForOptions |
|
Options controlling the wait |
public async waitForAndSelectElement(fromNode: SomeElement, selector: string, options: WaitForOptions): PromiseSomeElement> source
import {waitForAndSelectElement} from 'lib/delays.js'
Calls fromNode.querySelector
using the supplied selector. If the
return value of the first calls is null/undefined then waits for the same call
to return a truthy value and then returns the element the selector matches.
Params:
Name | Type | Attribute | Description |
fromNode | SomeElement | The element the to be selected |
|
selector | string | The querySelector to use for |
|
options | WaitForOptions |
|
Options controlling the wait |
public waitForEventTargetToFireEvent(eventTarget: EventTarget, event: string, max: number): Promise<boolean> source
import {waitForEventTargetToFireEvent} from 'lib/events.js'
Returns a promise that resolves to true once the supplied event is fired from the supplied
event target. If max
is supplied and the event is not fired by max
the promise resolves to false.
public waitForHistoryManipToChangeLocation(previousLocation: string, options: WaitForOptions): Promise<boolean> source
import {waitForHistoryManipToChangeLocation} from 'lib/browser.js'
Waits for the value of window.location.href
to differ from
the supplied value due to browser history manipulation. If actual navigation
causes a change this function is useless. The default poll rate is 1 second
and the safety timeout is 5 seconds.
Params:
Name | Type | Attribute | Description |
previousLocation | string | The value of |
|
options | WaitForOptions |
|
Optional options
for controlling the checks poll rate and the safety timeout length.
Supplied values for |
public waitForPredicate(predicate: function(): boolean, options: WaitForOptions): Promise<WaitResult> source
import {waitForPredicate} from 'lib/delays.js'
Returns a promise that resolves once the supplied predicate function returns a truthy value.
Params:
Name | Type | Attribute | Description |
predicate | function(): boolean | A predicate function that returns a truthy value to indicate the wait condition was satisfied otherwise a falsy value to indicate wait condition not satisfied |
|
options | WaitForOptions |
|
Options controlling how the wait will happen |
public waitForSelector(config: WaitForSelectorOptions): Promise<WaitResult> source
import {waitForSelector} from 'lib/delays.js'
Waits for the supplied selector to exist
Params:
Name | Type | Attribute | Description |
config | WaitForSelectorOptions | Options controlling the wait |
public waitUntilElementIsRemovedFromDom(elem: SomeElement, options: WaitForOptions): Promise<WaitResult> source
import {waitUntilElementIsRemovedFromDom} from 'lib/delays.js'
Waits for the supplied element to be removed from the document.
The condition, element removed from document, is polled at the configured
pollRate
(defaults to 1 second) for a maximum of max
time (defaults to 15 seconds)
unless max = -1
which in this case there is no maximum.
Params:
Name | Type | Attribute | Description |
elem | SomeElement | The element that should be removed |
|
options | WaitForOptions |
|
Options controlling the wait |
public async * walkChildrenOfCustom(opts: WalkChildrenOfCustomOpts): AsyncIterableIterator<SomeElement> source
import {walkChildrenOfCustom} from 'lib/traversals.js'
Walks the children of the supplied parent element yielding its children.
If the loader option is true or shouldWait and or wait function(s) are supplied then the walk behaves as if the loader was set to true.
When operating in loader mode and a child of the parent element does not have a next element sibling, a wait for additional child elements to be added is done, if no custom wait function was supplied the wait happens for a maximum of 15 seconds. After the wait ends and if the current child element still does not have a next element sibling the generator ends.
When not operating in loader mode and the current child element does not have a next element sibling the traversal ends.
See the documentation for WalkChildrenOfCustomOpts for the customization options available
Params:
Name | Type | Attribute | Description |
opts | WalkChildrenOfCustomOpts | Options for configuring the walk |
public xpathOneOf(options: XPathOnOfOpts): Array<SomeElement> source
import {xpathOneOf} from 'lib/dom.js'
Returns the results of evaluating one of the supplied xpath queries if one of the queries yields results otherwise null/undefined
Params:
Name | Type | Attribute | Description |
options | XPathOnOfOpts |
public xpathSnapShot(xpathQuery: string, contextElement: SomeElement | Document): XPathResult source
import {xpathSnapShot} from 'lib/dom.js'
Returns the results of evaluating the supplied
xpath query using an optional context contextElement
, defaults
to document, as XPathResult.ORDERED_NODE_SNAPSHOT_TYPE
Params:
Name | Type | Attribute | Description |
xpathQuery | string | The xpath query to be evaluated |
|
contextElement | SomeElement | Document |
|
Optional element to be used as the context of the evaluation |
Return:
XPathResult | The results of the xpath query evaluation |
public xpathSnapShotArray(xpathQuery: string, contextElement: SomeElement | Document): Array<SomeElement> source
import {xpathSnapShotArray} from 'lib/dom.js'
Provides the same functionality of the chrome console utility $x
but likely less performant
Params:
Name | Type | Attribute | Description |
xpathQuery | string | The xpath query to be evaluated |
|
contextElement | SomeElement | Document |
|
Optional element to be used as the context of the evaluation |