Giter VIP home page Giter VIP logo

puppeteer-api-typescript-examples's Introduction

puppeteer-api-typescript-examples - UPDATED NOV 2023

This repo contains examples of how to create page objects and tests using puppeteer and TypeScript. The application under test is tourdedave's "the-internet" project which contains examples of hard to automate pages. The test framework is mocha.

Dependencies

  • Node.js version 8 or greater

Test execution

To run the tests, execute npm install, npm run build then npm test.

Run single spec file without transpiling

./node_modules/.bin/mocha --timeout 10000 --require ts-node/register <spec_file>.ts
./node_modules/.bin/mocha --timeout 10000 --require ts-node/register src/tests/brokenimages.spec.ts

TODO NOV 2023

Add eslint, I had to remove tslint to get the tests to pass.s

TEST SUITE RESULTS NOV 2023

Still works after all these years! Puppeteer rocks!

$ npm install && npm run build && npm test

up to date, audited 298 packages in 849ms

40 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] build
> rimraf lib && npm run moveJsonFiles && tsc --outDir lib


> [email protected] moveJsonFiles
> copyfiles -u 1 src/selectors/* src/config/* lib


> [email protected] test
> mocha --timeout 999999 --reporter mochawesome lib/index.js



  Key presses test

  Puppeteer old Headless deprecation warning:
    In the near future `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

    ✔ Press F5 key, scrape result (1502ms)
    ✔ Press a key, scrape result (257ms)
    ✔ Press 1 key, scrape result (273ms)
    ✔ Press b key, scrape result (275ms)
    ✔ Press Alt key, scrape result (268ms)
    ✔ Press Shift key, scrape result (231ms)

  Authentication test:

  Puppeteer old Headless deprecation warning:
    In the near future `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

    ✔ Login test (768ms)
    ✔ Validation Message Test (1124ms)
    ✔ Close Validation Message Test (741ms)

  Hover over image test:

  Puppeteer old Headless deprecation warning:
    In the near future `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

    ✔ Hover over images test, user 0 (1159ms)
    ✔ Hover over images test, user 1 (624ms)
    ✔ Hover over images test, user 2 (589ms)

  JavaScript alerts test

  Puppeteer old Headless deprecation warning:
    In the near future `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

    ✔ JavaScript alert test


  13 passing (11s)

puppeteer-api-typescript-examples's People

Stargazers

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