Richard Wilde @rippo
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
Chrome is based on Chromium!
Puppeteer is a Node library which provides a high-level API to control headless Chrome (AKA Chromium) over the DevTools Protocol. It can also be configured to use (non-headless) Chrome.
$ npm install -g yarn #I recommend this as a replacement for npm
$ yarn init
$ yarn add --dev puppeteer mocha chai
$ yarn add --dev yargs looks-same
Optional (used during this demo)
Tech giants like facebook and google decided to team up and make a better package management tool, they called it Yarn.
You will need node! https://nodejs.org
$ cd D:\Projects\Presentations\puppeteer
$ node grabs/grab01.js --showNote: its is possible to change the viewport size
await page.setViewport({ width:1024, height:800});is a feature-rich JavaScript test framework running on Node.js and in the browser.
is a BDD / TDD assertion library for node and the browser that can be delightfully paired withany javascript testing framework.
Source: Blog Post https://goo.gl/FSHWBL
Create the following files:-
$ mocha --timeout 10000 ./runner.js tests/test01.js --showNOTE: The actual HTML page is sandboxed. To get access to the page DOM we use evaluate.
$ mocha --timeout 10000 ./runner.js tests/test02.jsWhats the weather like today?
Remember remote calls takes time to get the data and to render!
$ mocha --timeout 10000 ./runner.js tests/test03.jsVisual regression testing, is it a good idea?
For a good overview see
$ mocha --timeout 10000 ./runner.js tests/metrics/test04.jsWhats the weather like today?
Remember remote calls takes time to get the data and to render!
Login
Page
Search
Page
Page Objects
login.as.test1.user.js
Login Test Pages
login.as.test2.user.js
login.as.unknown.user.js
invalid.search.js
Search Test Pages
valid.search.js
empty.results.search.js
tests/test0?.js
tests/**/test0?.js
mocha --reporter mocha-teamcity-reporter
Git Hub repository:
https://github.com/rippo/puppeteer.presentation.50mins
Page object pattern
http://martinfowler.com/bliki/PageObject.html
Hit me on twitter @rippo