Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zahradnik-ondrej/puppethelper
A Puppeteer utility package for web automation.
https://github.com/zahradnik-ondrej/puppethelper
automation browser puppeteer qa web
Last synced: 3 months ago
JSON representation
A Puppeteer utility package for web automation.
- Host: GitHub
- URL: https://github.com/zahradnik-ondrej/puppethelper
- Owner: zahradnik-ondrej
- License: gpl-3.0
- Created: 2024-06-12T22:39:20.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-12T22:46:28.000Z (7 months ago)
- Last Synced: 2024-09-30T15:18:01.288Z (3 months ago)
- Topics: automation, browser, puppeteer, qa, web
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/puppethelper
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🧰 puppethelper
### A Puppeteer utility package for web automation.
_(The instructions below have been made to work on **Linux** operating systems, specifically on **Ubuntu 22.04**)_
---
### Installation of the package:
1. `sudo apt update`
2. `sudo apt upgrade -y`
3. `wget -qO- https://deb.nodesource.com/setup_20.x | sudo -E bash -`
4. `sudo apt install -y nodejs`
5. `npm install puppethelper`
---
### Running the demo:
1. Run the commands shown in [Installation of the package](https://github.com/zahradnik-ondrej/puppethelper?tab=readme-ov-file#installation-of-the-package).
2. `sudo apt install git`
3. `git clone https://github.com/zahradnik-ondrej/puppethelper.git`
4. `cd puppethelper/bot-demo`
5. `npm start`
---
### Functions:
```typescript
// clears a text field
clear(page: Page, selector: string)
``````typescript
// clicks on an element
click(page: Page, selector: string, timeout: number = 30)
``````typescript
// waits for an element to be loaded
findElement(page: Page, selector: string, timeout: number = 30)
``````typescript
// returns the attribute value of an element
getAttribute(page: Page, selector: string, attribute: string)
``````typescript
// returns the text within an element
getText(page: Page, selector: string)
``````typescript
// waits for a specified number of seconds
timeout(seconds: number = 5)
``````typescript
// types a string into a text field
type(page: Page, selector: string, text: string, timeout: number = 30)
```### Errors:
```typescript
AttributeNotFound(attribute: string, selector: string)
``````typescript
ElementNotFound(selector: string)
```### Constants:
```typescript
type ModeType = boolean | 'shell'const browser_opts: {
headless: ModeType
slowMo: number
devtools: boolean
executablePath: string
args: string[]
} = {
headless: true,
slowMo: 1,
devtools: false,
executablePath: '/usr/bin/chromium-browser',
args: ['--no-sandbox', '--disable-setuid-sandbox'],
}
``````typescript
const page_opts: { default_timeout: number } = {
default_timeout: 30000,
}
```### Types:
```typescript
type SelectorType = 'css' | 'xpath'
```