Botmation Documentation
Input
Input
These BotAction's provide ways to input into a page as User.
Click
Does a left-mouse click on the first HTML element that matches the provided HTML selector.
const click = (selector: string): BotAction => async(page) => await page.click(selector)
Example:
await chain( click('form input[type="submit"]'), waitForNavigation)(page)
Click Text
Does a left-mouse click on the first element found whose text content equals the text provided.
const clickText = (text: string): BotAction => evaluate(clickElementWithText, text)
Example:
chain( clickText('Save Info'))(page)
This will click the DOM element with the text "Save Info".
Type
Type with an imaginary "keyboard" the copy provided.
const type = (copy: string): BotAction => async(page) => await page.keyboard.type(copy)
Example:
await chain( click('form input[name="email"]'), type('example@email.com'))(page)
Helpers
clickElementWithText
const clickElementWithText = (text: string) => { const xpath = `//*[text()='${text}']` const matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (matchingElement instanceof HTMLElement) { matchingElement.click() }}