-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Randomness, Instagram View Stories, and more (#29)
* Randomness * fix gatsby/react console errors * Randomness Docs Polish * deleteIndexedDB doc * getCookies, deleteCookies docs * Cookies & Scrapers docs * indexedDB, input, random docs - added missing helpers * instagram nav, auth, stories docs * homepage polish * overview polish * install polish * aborting polish * removing 'export' from code displayed * instagram botactions designed at desktop width - adjust example to set Viewport to desktop width to fix viewStories
- Loading branch information
Showing
15 changed files
with
502 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,20 +5,36 @@ title: 'Input' | |
These BotAction's provide ways to input into a page as User. | ||
|
||
## Click | ||
Does a left-mouse click on a HTML element by the provided HTML selector. | ||
Does a left-mouse click on the first HTML element that matches the provided HTML selector. | ||
|
||
```typescript | ||
const click = (selector: string): BotAction => async(page) => | ||
await page.click(selector) | ||
``` | ||
Example: | ||
Example: | ||
```typescript | ||
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. | ||
|
||
```typescript | ||
const clickText = (text: string): BotAction => | ||
evaluate(clickElementWithText, text) | ||
``` | ||
|
||
Example: | ||
```typescript | ||
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. | ||
|
||
|
@@ -27,10 +43,25 @@ const type = (copy: string): BotAction => async(page) => | |
await page.keyboard.type(copy) | ||
``` | ||
|
||
Example: | ||
Example: | ||
```typescript | ||
await chain( | ||
click('form input[name="username"]'), | ||
type('my-username') | ||
click('form input[name="email"]'), | ||
type('[email protected]') | ||
)(page) | ||
``` | ||
|
||
## Helpers | ||
|
||
### clickElementWithText | ||
|
||
```typescript | ||
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() | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.