Giter Club home page Giter Club logo

lutkar's Introduction

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()

lutkar's People

Contributors

aaronchen avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.