Builtin actions

Table of contents

check

check(prop: IDomProp | string) => Promise<void>

Checks a checkbox prop if it is not already checked.

ayakashi.selectOne("myCheckboxProp").where({id: {eq: "myCheckbox"}});
await ayakashi.check("myCheckboxProp");

clearInput

clearInput(prop: IDomProp | string, charCount?: undefined | number) => Promise<void>

Clears the text in a prop by pressing Backspace until the value is cleared.

A character count can be specified to only clear part of the text.

ayakashi.selectOne("myInput").where({id: {eq: "name"}});
await ayakashi.clearInput("myInput");

click

click(prop: IDomProp | string) => Promise<void>

Clicks on a prop

ayakashi.selectOne("myButtonProp").where({class: {eq: "btn"}});
await ayakashi.click("myButtonProp");

doubleClick

doubleClick(prop: IDomProp | string) => Promise<void>

Double-clicks on a prop

ayakashi.selectOne("myButtonProp").where({class: {eq: "btn"}});
await ayakashi.doubleClick("myButtonProp");

focus

focus(prop: IDomProp | string) => Promise<void>

Focuses on a prop

ayakashi.selectOne("myInput").where({id: {eq: "email"}});
await ayakashi.focus("myInput");

getNodeId

getNodeId(prop: IDomProp | string) => Promise<number>

Returns the DOM nodeId of a prop. Mostly for internal use or to implement other actions.

ayakashi.selectOne("myButton").where({class: {eq: "btn"}});
await ayakashi.getNodeId("myButton");

getPosition

getPosition(prop: IDomProp | string) => Promise<{}>

Returns the x and y coordinates of a prop.

ayakashi.selectOne("myButton").where({class: {eq: "btn"}});
await ayakashi.getPosition("myButton");

goTo

goTo(url: string, timeout?: undefined | number) => Promise<void>

Navigates to a new page and waits for the document to load.

A timeout can be specified (in ms) for slow pages (default 10s).

Use a timeout of 0 to disable the timeout.

Learn more at https://ayakashi.io/docs/going_deeper/page-navigation.html#standard-navigation

await ayakashi.goTo("https://ayakashi.io");

hover

hover(prop: IDomProp | string) => Promise<void>

Hovers over a prop.

ayakashi.selectOne("moreInfo").where({id: {eq: "info"}});
await ayakashi.hover("moreInfo");

infiniteScrollIn

infiniteScrollIn(prop: IDomProp | string, options?: undefined | undefined) => Promise<void>

Infinitely scrolls inside a scrollable prop.

Works with props that load more content and expand dynamically as they are being scrolled.

A callback can be triggered on each scrolling interval to extract data as we scroll.

The scrolling interval can be controlled with the interval option (default 1s).

The pixels to scroll each time can be controlled with the pixelsToScroll option.

If no pixelsToScroll is provided it will scroll to the (current) bottom of the prop.

The scrolling can be stopped with the stopScrollingAfter option (in ms) or if the final bottom is reached and no more content is available.

ayakashi.selectOne("myInfiniteScrollableDiv").where({class: {eq: "scrollableList"}});
await ayakashi.infiniteScrollIn("myInfiniteScrollableDiv", {
cb: function(currentHeight) {
console.log("scrolling infinitely");
console.log("current height", currentHeight);
//let data flow in as we scroll
}
});
navigationClick(prop: IDomProp | string, timeout?: undefined | number) => Promise<void>

Clicks on a prop to navigate to a new page.

It should be used instead of click() so the new page can properly load.

A timeout can be specified (in ms) for slow pages (default 10s).

Use a timeout of 0 to disable the timeout.

Learn more at https://ayakashi.io/docs/going_deeper/page-navigation.html#click-to-navigate

ayakashi
.select("myLink")
.where({id: {eq: "theLink"}});
await ayakashi.navigationClick("myLink");

rightClick

rightClick(prop: IDomProp | string) => Promise<void>

Right-clicks on a prop

ayakashi.selectOne("menuOpener").where({class: {eq: "menu-trigger"}});
await ayakashi.rightClick("menuOpener");

scrollIn

scrollIn(prop: IDomProp | string, pixelsToScroll?: undefined | number) => Promise<number>

Scrolls inside a scrollable prop by an amount of pixels.

If no pixels are specified it will scroll to the bottom of the prop.

Works for props with a static height.

Check the scrollInUntilBottomIsReached() and infiniteScrollIn() actions If the prop loads more content and expands dynamically as it is being scrolled.

ayakashi.selectOne("myScrollableDiv").where({class: {eq: "scrollableList"}});
await ayakashi.scrollIn("myScrollableDiv");

scrollInUntilBottomIsReached

scrollInUntilBottomIsReached(prop: IDomProp | string, scrollInterval?: undefined | number, timeout?: undefined | number) => Promise<void>

Scrolls inside a scrollable prop until its bottom is reached.

Works with props that load more content and expand dynamically as they are being scrolled.

The scrolling interval can be controlled with the interval parameter.

A timeout can be specified (in ms) to throw an error if the time is exceeded (default 10s) and the bottom is still not reached.

Use a timeout of 0 to disable the timeout.

ayakashi.selectOne("myDynamicScrollableDiv").where({class: {eq: "scrollableList"}});
await ayakashi.scrollInUntilBottomIsReached("myDynamicScrollableDiv");

scrollIntoView

scrollIntoView(prop: IDomProp | string) => Promise<void>

Scrolls a prop into view.

ayakashi.selectOne("myButtonProp").where({class: {eq: "btn"}});
await ayakashi.scrollIntoView("myButtonProp");

spaNavigationClick

spaNavigationClick(prop: IDomProp | string, timeout?: undefined | number) => Promise<void>

Clicks on a prop that changes the view in a dynamic page or single page application.

It should be used instead of click() so the view can properly load.

It will not reload the page like navigationClick().

A timeout can be specified (in ms) for slow pages (default 10s).

Use a timeout of 0 to disable the timeout.

Learn more at https://ayakashi.io/docs/going_deeper/page-navigation.html#single-page-application-spa-navigation

ayakashi
.select("inPageLink")
.where({id: {eq: "theLink"}});
await ayakashi.spaNavigationClick("inPageLink");

tap

tap(prop: IDomProp | string) => Promise<void>

Taps on a prop. Same as click() but dispatches touch events instead of mouse events.

ayakashi.selectOne("myButtonProp").where({class: {eq: "btn"}});
await ayakashi.tap("myButtonProp");

typeIn

typeIn(prop: IDomProp | string, text: string) => Promise<void>

Types text in a prop by pressing each character one by one with a delay.

ayakashi.selectOne("searchBox").where({id: {eq: "search"}});
await ayakashi.typeIn("searchBox", "web scraping and sanity");

uncheck

uncheck(prop: IDomProp | string) => Promise<void>

Unchecks a checkbox prop if it is already checked.

ayakashi.selectOne("myCheckboxProp").where({id: {eq: "myCheckbox"}});
await ayakashi.uncheck("myCheckboxProp");

wait

wait(timeout?: undefined | number) => Promise<void>

Waits for a specified amount of ms.

await ayakashi.wait(3000);

waitForDomContentLoadedEvent

waitForDomContentLoadedEvent(timeout?: undefined | number) => Promise<void>

Waits for the domContentLoaded event of a new page.

Learn more at https://ayakashi.io/docs/going_deeper/page-navigation.html#using-the-raw-events

waitForInPageNavigation

waitForInPageNavigation(timeout?: undefined | number) => Promise<void>

Waits for an in-page navigation to occur in a dynamic page or single page application.

Learn more at https://ayakashi.io/docs/going_deeper/page-navigation.html#using-the-raw-events

waitForLoadEvent

waitForLoadEvent(timeout?: undefined | number) => Promise<void>

Waits for the load event of a new page.

Learn more at https://ayakashi.io/docs/going_deeper/page-navigation.html#using-the-raw-events

waitUntil

waitUntil(cb, interval?: undefined | number, timeout?: undefined | number) => Promise

Waits by executing the callback until it returns a truthy value in a set interval.

The interval parameter can configure the callback execution interval (default 100ms).

A timeout can be specified (in ms) to throw an error if the time is exceeded (default 10s).

await ayakashi.waitUntil(function() {
return ayakashi.evaluate(function() {
//check for something in the page
});
});

waitUntilExists

waitUntilExists(prop: IDomProp | string, timeout?: undefined | number) => Promise<void>

Waits until a prop exists on the page by re-evaluating its query until it finds a match.

A timeout can be specified (in ms) to throw an error if the time is exceeded (default 10s).

Use a timeout of 0 to disable the timeout.

ayakashi
.select("myProp")
.where({class: {eq: "dynamicContainer"}});
await ayakashi.waitUntilExists("myProp");

waitUntilVisible

waitUntilVisible(prop: IDomProp | string, timeout?: undefined | number) => Promise<void>

Waits until a prop exists on the page and is also visible.

A timeout can be specified (in ms) to throw an error if the time is exceeded (default 10s).

Use a timeout of 0 to disable the timeout.

ayakashi
.select("myProp")
.where({class: {eq: "dynamicContainer"}});
await ayakashi.waitUntilVisible("myProp");