SlideShare a Scribd company logo
1 of 32
Puppeteer 101
Mark Robin
Full-Stack Software Engineer
cds extended 19
#cebu
Mark Robin
From Cebu City, Philippines
- Full-stack Software Engineer, Chromedia Far East Inc.
- Part-time freelancer
- Core team member & Technical Lead, GDG Cebu
- A huge sucker for tech stickers
- Single...
cds extended 19
#cebu
“Hey, send me a screenshot of
www.example.com.”
- Boss
cds extended 19
#cebu
“Hey, send me a screenshot of
www.example.com everyday.”
- Boss
Hmm...
cds extended 19
#cebu
“Anything that you do more than twice has
to be automated.”
- Adam Stone, CEO, D-Tools
can
cds extended 19
#cebu
Puppeteer
- a Node library which provides a high-level API to control Chrome or
Chromium over the DevTools Protocol
- runs headless by default, but can be configured to run full
(non-headless) Chrome or Chromium.
cds extended 19
#cebu
“So what can we do with Puppeteer?”
Most of the things we can do
manually in the browser.
cds extended 19
#cebu
What can we do with Puppeteer?
● Generate screenshots and PDFs of pages.
● Crawl a SPA (Single-Page Application) and generate pre-rendered content
(i.e. "SSR" (Server-Side Rendering)).
● Automate form submission, UI testing, keyboard input, etc.
● Create an up-to-date, automated testing environment. Run your tests
directly in the latest version of Chrome using the latest JavaScript and
browser features.
● Capture a timeline trace of your site to help diagnose performance issues.
● Test Chrome Extensions.
● And many more!
cds extended 19
#cebu
npm install puppeteer
# or "yarn add puppeteer"
npm install puppeteer-core
# or "yarn add puppeteer-core"
cds extended 19
#cebu
Take a screenshot
cds extended 19
#cebu
Generate PDF
cds extended 19
#cebu
Scrap content
cds extended 19
#cebu
Time tracing
cds extended 19
#cebu
Automate UI testing
cds extended 19
#cebu
cds extended 19
#cebu
Debugging Puppeteer
cds extended 19
#cebu
My use case is with
Automation UI testing
cds extended 19
#cebu
“End-to-end testing is a methodology used to test
whether the flow of an application is performing
as designed from start to finish. The purpose of
carrying out end-to-end tests is to identify system
dependencies and to ensure that the right
information is passed between various system
components and systems.” - Techopedia
Sources:
https://www.techopedia.com/definition/7035/end-to-end-test cds extended 19
#cebu
“Hey, send me a screenshot of
www.example.com everyday.”
- Boss
Pfft...EZ
cds extended 19
#cebu
“Hey, send me screenshots of
mobile, table and desktop views
of www.example.com everyday.”
- Boss
cds extended 19
#cebu
SAY WHAT
cds extended 19
#cebu
Device Emulation
● User Agent
● Device Pixel Ratio
● Viewport Size
● Touch Support
cds extended 19
#cebu
100+ Devices
cds extended 19
#cebu
Tests are slowTests are slow
fast
cds extended 19
#cebu
Tests are slow
● Browser context
fast
cds extended 19
#cebu
100x faster!
cds extended 19
#cebu
Lighthouse - an open-source, automated tool for improving
the quality of web pages.
It uses Puppeteer!
https://developers.google.com/web/tools/lighthouse
cds extended 19
#cebu
Additional Examples
https://developers.google.com/web/tools/puppeteer/examples
cds extended 19
#cebu
Rendering and web scraping
● Puppetron - Demo site that shows how to use Puppeteer and Headless Chrome to render pages.
Inspired by GoogleChrome/rendertron.
● Thal - Getting started with Puppeteer and Chrome Headless for Web Scraping.
● pupperender - Express middleware that checks the User-Agent header of incoming requests, and if it
matches one of a configurable set of bots, render the page using Puppeteer. Useful for PWA
rendering.
● headless-chrome-crawler - Crawler that provides simple APIs to manipulate Headless Chrome and
allows you to crawl dynamic websites.
● puppeteer-examples - Puppeteer Headless Chrome examples for real life use cases such as getting
useful info from the web pages or common login scenarios.
● browserless - Headless Chrome as a service letting you execute Puppeteer scripts remotely.
Provides a docker image with configuration for concurrency, launch arguments and more.
● Puppeteer Sandbox - Puppeteer sandbox environment as a service. Runs Puppeteer scripts and
allows saving and embedding them in external sites and markdown files.
cds extended 19
#cebu
Testing
● angular-puppeteer-demo - Demo repository explaining how to use Puppeteer in Karma.
● mocha-headless-chrome - Tool which runs client-side mocha tests in the command line through
headless Chrome.
● puppeteer-to-istanbul-example - Demo repository demonstrating how to output Puppeteer coverage
in Istanbul format.
● jest-puppeteer - (almost) Zero configuration tool for setting up and running Jest and Puppeteer
easily. Also includes an assertion library for Puppeteer.
● puppeteer-har - Generate HAR file with puppeteer.
● puppetry - A desktop app to build Puppeteer/Jest driven tests without coding.
Services
● Checkly - Monitoring SaaS that uses Puppeteer to check availability and correctness of web pages
and apps. cds extended 19
#cebu
https://www.linkedin.com/in/markdrobin/
https://github.com/mdrobin95/puppeteer-demo
Credits and Resources
● meme.at
● streaks.arnelle.me/
● www.techopedia.com/definition/7035/end-to-end-test
● developers.google.com/web/tools/puppeteer
● flood.io/blog/selenium-vs-puppeteer-for-test-automation-is-a-new-leader-emerging/
cds extended 19
#cebu

More Related Content

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Featured

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Puppeteer101: Automation Made Awesome

  • 1. Puppeteer 101 Mark Robin Full-Stack Software Engineer cds extended 19 #cebu
  • 2. Mark Robin From Cebu City, Philippines - Full-stack Software Engineer, Chromedia Far East Inc. - Part-time freelancer - Core team member & Technical Lead, GDG Cebu - A huge sucker for tech stickers - Single... cds extended 19 #cebu
  • 3. “Hey, send me a screenshot of www.example.com.” - Boss cds extended 19 #cebu
  • 4. “Hey, send me a screenshot of www.example.com everyday.” - Boss Hmm... cds extended 19 #cebu
  • 5. “Anything that you do more than twice has to be automated.” - Adam Stone, CEO, D-Tools can cds extended 19 #cebu
  • 6. Puppeteer - a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol - runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium. cds extended 19 #cebu
  • 7. “So what can we do with Puppeteer?” Most of the things we can do manually in the browser. cds extended 19 #cebu
  • 8. What can we do with Puppeteer? ● Generate screenshots and PDFs of pages. ● Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. "SSR" (Server-Side Rendering)). ● Automate form submission, UI testing, keyboard input, etc. ● Create an up-to-date, automated testing environment. Run your tests directly in the latest version of Chrome using the latest JavaScript and browser features. ● Capture a timeline trace of your site to help diagnose performance issues. ● Test Chrome Extensions. ● And many more! cds extended 19 #cebu
  • 9. npm install puppeteer # or "yarn add puppeteer" npm install puppeteer-core # or "yarn add puppeteer-core" cds extended 19 #cebu
  • 10. Take a screenshot cds extended 19 #cebu
  • 14. Automate UI testing cds extended 19 #cebu
  • 17. My use case is with Automation UI testing cds extended 19 #cebu
  • 18. “End-to-end testing is a methodology used to test whether the flow of an application is performing as designed from start to finish. The purpose of carrying out end-to-end tests is to identify system dependencies and to ensure that the right information is passed between various system components and systems.” - Techopedia Sources: https://www.techopedia.com/definition/7035/end-to-end-test cds extended 19 #cebu
  • 19. “Hey, send me a screenshot of www.example.com everyday.” - Boss Pfft...EZ cds extended 19 #cebu
  • 20. “Hey, send me screenshots of mobile, table and desktop views of www.example.com everyday.” - Boss cds extended 19 #cebu
  • 22. Device Emulation ● User Agent ● Device Pixel Ratio ● Viewport Size ● Touch Support cds extended 19 #cebu
  • 24. Tests are slowTests are slow fast cds extended 19 #cebu
  • 25. Tests are slow ● Browser context fast cds extended 19 #cebu
  • 27. Lighthouse - an open-source, automated tool for improving the quality of web pages. It uses Puppeteer! https://developers.google.com/web/tools/lighthouse cds extended 19 #cebu
  • 29. Rendering and web scraping ● Puppetron - Demo site that shows how to use Puppeteer and Headless Chrome to render pages. Inspired by GoogleChrome/rendertron. ● Thal - Getting started with Puppeteer and Chrome Headless for Web Scraping. ● pupperender - Express middleware that checks the User-Agent header of incoming requests, and if it matches one of a configurable set of bots, render the page using Puppeteer. Useful for PWA rendering. ● headless-chrome-crawler - Crawler that provides simple APIs to manipulate Headless Chrome and allows you to crawl dynamic websites. ● puppeteer-examples - Puppeteer Headless Chrome examples for real life use cases such as getting useful info from the web pages or common login scenarios. ● browserless - Headless Chrome as a service letting you execute Puppeteer scripts remotely. Provides a docker image with configuration for concurrency, launch arguments and more. ● Puppeteer Sandbox - Puppeteer sandbox environment as a service. Runs Puppeteer scripts and allows saving and embedding them in external sites and markdown files. cds extended 19 #cebu
  • 30. Testing ● angular-puppeteer-demo - Demo repository explaining how to use Puppeteer in Karma. ● mocha-headless-chrome - Tool which runs client-side mocha tests in the command line through headless Chrome. ● puppeteer-to-istanbul-example - Demo repository demonstrating how to output Puppeteer coverage in Istanbul format. ● jest-puppeteer - (almost) Zero configuration tool for setting up and running Jest and Puppeteer easily. Also includes an assertion library for Puppeteer. ● puppeteer-har - Generate HAR file with puppeteer. ● puppetry - A desktop app to build Puppeteer/Jest driven tests without coding. Services ● Checkly - Monitoring SaaS that uses Puppeteer to check availability and correctness of web pages and apps. cds extended 19 #cebu
  • 32. Credits and Resources ● meme.at ● streaks.arnelle.me/ ● www.techopedia.com/definition/7035/end-to-end-test ● developers.google.com/web/tools/puppeteer ● flood.io/blog/selenium-vs-puppeteer-for-test-automation-is-a-new-leader-emerging/ cds extended 19 #cebu