Skip to content

Puppeteer plugin to enhance its automation features.

Notifications You must be signed in to change notification settings

aaronchen/lutkar

Repository files navigation

Install

git clone https://github.com/aaronchen/lutkar.git
cd lutkar
npm install

Automation: Lutkar (Puppeteer Plugin)

Lutkar is based on puppeteer, and uses puppeteer-extra and puppeteer-extra-plugin to enhance its automation features.

It overrides Page and Frame objects to add additional methods, bring in implicit wait, and minimizes the need to use explicit wait.

It also overrides ElementHandle to add more Element methods.

Test Framework: Mocha.js

mocha and chai are the libraries used to manage test suites/cases, and mochawesome for test reports.

Structure

Test Suite

.mocharc.yml and helpers/mocha.js are configured for easy test suite creation.

// Create the following test suite in test/google.spec.js,
// and execute `npm test` to run automation test and generate the report.
describe('Google', function () {
  it('can search puppeteer and mark its page navigation', async function () {
    await page.goto('https://www.google.com')
    await page.type('[name="q"]', 'puppeteer')
    await page.keyboard.press('Enter')

    await page.scrollIntoView('#footcnt')
    await page.drawRectangle('[role="navigation"] table')
    await page.screenshot('./screens/google.png')
  })
})

Test Case

// sample.js:  Just use chromium.js for automation.
// To run: `node sample.js`
import chromium from './helpers/chromium.js'

const browser = await chromium()
const page = await browser.newPage()

await page.goto('https://www.google.com')
await page.type('[name="q"]', 'puppeteer')
await page.keyboard.press('Enter')
// Navigating to a new page (No explicit wait required)

await page.click('[role="navigation"] .fl:eq(3)') // Go to page 5 of navigation
// Navigating to a new page (No explicit wait required)

const navigation = await page.$('[role="navigation"] table')
await navigation.scrollIntoView()
await navigation.drawRectangle()
await page.screenshot('./screens/google.png') // Screenshot of page 5 navigation

await browser.close()

About

Puppeteer plugin to enhance its automation features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published