Skip to content

zahradnik-ondrej/puppethelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧰 puppeteer-helper

A Puppeteer utility module for web automation.


Functions:

// clears a text field
clear(page: Page, selector: string)
// clears a text field by simulating the user pressing the `Backspace` key
clearManual(page: Page, selector: string, attribute: string = 'value')
// clicks on an element
click(page: Page, selector: string, timeout: number = 30)
executeCommand(command: string, password?: string)
// expects a selector's attribute to be of a specified value
expectAttribute(page: Page, selector: string, attribute: string, value: string, timeout: number = 30)
// expects a specified text within an element
expectText(page: Page, selector: string, text: string, timeout: number = 30)
getAttribute(page: Page, selector: string, attribute: string)
getText(page: Page, selector: string)
// generates a random integer within a specified range
randomInt(min: number = 0, max: number = 9)
timeout(seconds: number = 5)
// types a string into a text field
type(page: Page, selector: string, text: string, timeout: number = 30)
// waits for a element to be loaded
waitForSelector(page: Page, selector: string, timeout: number = 30)

Errors:

  • SelectorNotFound
  • CustomError - Meant to be used for miscellaneous errors which you might expect during testing but are not errors within the test suite itself. It is displayed differently from regular errors when using the custom-mocha-spec-reporter.js.

Constants:

const BROWSER_OPTS: {headless: HeadlessOption, slowMo: number, devtools: boolean, executablePath: string} = {
    headless: 'new',
    slowMo: 1,
    devtools: false,
    executablePath: '/usr/bin/chromium-browser',
}
const PAGE_OPTS: {DEFAULT_TIMEOUT: number} = {
  DEFAULT_TIMEOUT: 30000,
}

Scripts:

  • custom-mocha-spec-reporter.js

About

A Puppeteer helper package for automated QA web testing.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published