1.0.5 • Published 1 year ago

puppethelper v1.0.5

Weekly downloads
-
License
GNU General Publi...
Repository
github
Last release
1 year ago

🧰 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.

  2. sudo apt install git

  3. git clone https://github.com/zahradnik-ondrej/puppethelper.git

  4. cd puppethelper/bot-demo

  5. npm start


Functions:

// clears a text field
clear(page: Page, selector: string)
// clicks on an element
click(page: Page, selector: string, timeout: number = 30)
// waits for an element to be loaded
findElement(page: Page, selector: string, timeout: number = 30)
// returns the attribute value of an element
getAttribute(page: Page, selector: string, attribute: string)
// returns the text within an element
getText(page: Page, selector: string)
// waits for a specified number of seconds
timeout(seconds: number = 5)
// types a string into a text field
type(page: Page, selector: string, text: string, timeout: number = 30)

Errors:

AttributeNotFound(attribute: string, selector: string)
ElementNotFound(selector: string)

Constants:

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'],
}
const page_opts: { default_timeout: number } = {
  default_timeout: 30000,
}

Types:

type SelectorType = 'css' | 'xpath'
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.13.6

2 years ago

1.13.5

2 years ago

1.13.4

2 years ago

1.13.3

2 years ago

1.13.9

2 years ago

1.13.8

2 years ago

1.13.7

2 years ago

1.13.2

2 years ago

1.13.1

2 years ago

1.13.0

2 years ago

1.12.1

2 years ago

1.12.0

2 years ago

1.11.6

2 years ago

1.11.5

2 years ago

1.11.4

2 years ago

1.11.3

2 years ago

1.11.2

2 years ago

1.11.1

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago