SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Automate everything via
NodeJS and Puppeteer
Table of Contents
01
OVERVIEW
What is puppeteer
& Tech stack
02
USE CASE
What you can do
with these power
03
REAL USAGE
Professional/Personal
real examples
04
CONCLUSIONS
Sums it up and
Q&A session
Who am I?
Hi👋👋, I’m Miki Lombardi
from Florence, Italy!
I’m a Full Stack Engineer @
Growens - BU MailUp and
Co-Founder @ Schrodinger
Hat
On the web you can find me
anywhere as @thejoin95 or
on mikilombardi.com
It is an italian community, an open source organization, a podcast, a
series of in-person event and live streaming with the goals of sharing
love, knowledge and help other devs.
You can learn more about on schrodinger-hat.it and
github.com/schrodinger-hat
Links available on the website
What is Schrodinger Hat
OVERVIEW
A small introduction before we dive into it
1
What is
Puppeteer?
“
”
Puppeteer is a Node library which
provides a high-level API to control
Chrome or Chromium over the
DevTools Protocol. Puppeteer runs
headless by default, but can be
configured to run full (non-headless)
Chrome or Chromium
It’s kind of
What it looks
like in a
schematic way
Ref: https://devdocs.io/puppeteer/
A brief history
Selenium is the old
one, still in the lead
thanks to its
ecosystem and cross
language framework
22K Github stars
114 KB min
Selenium
PhantomJS is now
archived and
deprecated. It was
the first headless
webkit with JS API
PhantomJS
Puppeteer is the
new sheriff in
town made by
Google, Chrome
team
74K Github stars
98KB min
Puppeteer
Thanks to the DevTools
protocol we can have access
to all the low-level
Chromium API using a high
level interface
The code it is very readable
and easy to write
spoiler: you need to be very modular
on the coding side
How is working
What we can do with
Puppeteer & Node?
Well, so...
Everything!
Get the best of it
Crawling any kind of
App (SPA, SSR
on/off..)
Testing out your
environment and App
Generating PDF /
Screenshot
Any kind of
automation
Performance Test in
the latest Chrome
Generating and
checking code coverage
A B C
D E F
Are there valid
alternatives to
Puppeteer?
The goal of this project (Microsoft, released in mid 2020) is to give a
really good tool for e2e testing in Node, Python, Java and .NET. It
works with all the major browser (Chromium, Firefox, Webkit) and it
can run contemporary test on every instance of the specified
navigators. Very powerful, it comes with some good feature over
Selenium too.
Fun fact: some ex core members of Puppeteer are working in Playwright projects,
that’s why it’s pretty the same (also the API and syntax)
Just one:
Playwright *not “The Mask”
Which one is better?
90% of the times the answer is:
it depends.
It depends on what are you needs and
what your goals are. If you need a e2e
testing lib, maybe Playwright is the choice.
You need also to consider other libraries
such as Cypress, with a great community.
Puppeteer is a general purpose lib in this
context, it’s very flexible with official
Google support
USE CASE
Let’s see how we can use Puppeteer
2
Scraping is very useful on PWA, SPA, SSR and can find out
vulnerabilities, performance leak, incorrect user journey, etc.
A lot of company (e.g. CodeSandbox) started to use
Puppeteer internally for testing purpose against their own
application.
Scraping
Apart from libraries such as Cypress, you can use Puppeteer in your
pipeline as e2e testing, automated UI testing, visual testing,
regression testing, integrate Jest, Mocha or other test frameworks.
All in one.
Testing
Assert that a product is show
on the search result page of
the Alibaba.com website after
typing in the search bar a
query name
Example
Using the DevTools protocol comes with advangetes such as
verifying the code coverage for our JS and CSS, testing out some
UI/UX feature such as a lazy loading feature or just speed up a
keyboard input process
Development utility
REAL
USAGE
Where the explosions begins
3
Scraping
The reason: I needed a vacation
Code available github.com/theJoin95/skyscanner-flights-scraping
Project goals:
- Create a private API layer to search flights
- Create a cron script to scrape and check the flights
- Create a CLI to check flights manually
- Get the cheapest flight to Oporto (Portugal) from Italy and enjoy
SkyScanner Scraper
This was me
Process
Automation
Code available on: github.com/schrodinger-Hat/youtube-to-
anchorfm/
As a podcaster, via Schrodinger Hat, we were streaming on YouTube
and Twitch our podcast episodes. Then, we were manually uploading
the audio file on Anchor.fm and published it on any podcast platform
Manually.
YouTube to Anchor.fm
We made a Github Action that take in input the latest video on our
YouTube channel and automatically convert it in an audio file, sign in
on Anchor.fm, upload the audio file and publish it.
Automatically.
GitHub Action + NodeJS
CONCLUSION
4
The end
My goal was to inspire you to try to
automate a process or activity with these
technology (or their alternatives)
In my opinion automation, in e2e testing
and UI testing, is the key in the
development of the modern applications
Puppeteer is an open source library on
Github. Feel free to contribute!
CREDITS: This presentation template was
created by Slidesgo, including icons by
Flaticon, and infographics & images by
Freepik
Do you have any questions?
miki.lombi@gmail.com
mikilombardi.com
Thanks!
CREDITS: This presentation template was
created by Slidesgo, including icons by
Flaticon, and infographics & images by
Freepik
QA?!
Please keep this slide for
attribution

Weitere ähnliche Inhalte

Empfohlen

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
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

Empfohlen (20)

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
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

stackconf 2022: Automate everything via NodeJS and Puppeteer

  • 2. Table of Contents 01 OVERVIEW What is puppeteer & Tech stack 02 USE CASE What you can do with these power 03 REAL USAGE Professional/Personal real examples 04 CONCLUSIONS Sums it up and Q&A session
  • 3. Who am I? Hi👋👋, I’m Miki Lombardi from Florence, Italy! I’m a Full Stack Engineer @ Growens - BU MailUp and Co-Founder @ Schrodinger Hat On the web you can find me anywhere as @thejoin95 or on mikilombardi.com
  • 4. It is an italian community, an open source organization, a podcast, a series of in-person event and live streaming with the goals of sharing love, knowledge and help other devs. You can learn more about on schrodinger-hat.it and github.com/schrodinger-hat Links available on the website What is Schrodinger Hat
  • 5. OVERVIEW A small introduction before we dive into it 1
  • 7. “ ” Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium
  • 9. What it looks like in a schematic way Ref: https://devdocs.io/puppeteer/
  • 10. A brief history Selenium is the old one, still in the lead thanks to its ecosystem and cross language framework 22K Github stars 114 KB min Selenium PhantomJS is now archived and deprecated. It was the first headless webkit with JS API PhantomJS Puppeteer is the new sheriff in town made by Google, Chrome team 74K Github stars 98KB min Puppeteer
  • 11. Thanks to the DevTools protocol we can have access to all the low-level Chromium API using a high level interface The code it is very readable and easy to write spoiler: you need to be very modular on the coding side How is working
  • 12. What we can do with Puppeteer & Node? Well, so...
  • 14. Get the best of it Crawling any kind of App (SPA, SSR on/off..) Testing out your environment and App Generating PDF / Screenshot Any kind of automation Performance Test in the latest Chrome Generating and checking code coverage A B C D E F
  • 16. The goal of this project (Microsoft, released in mid 2020) is to give a really good tool for e2e testing in Node, Python, Java and .NET. It works with all the major browser (Chromium, Firefox, Webkit) and it can run contemporary test on every instance of the specified navigators. Very powerful, it comes with some good feature over Selenium too. Fun fact: some ex core members of Puppeteer are working in Playwright projects, that’s why it’s pretty the same (also the API and syntax) Just one: Playwright *not “The Mask”
  • 17. Which one is better? 90% of the times the answer is: it depends. It depends on what are you needs and what your goals are. If you need a e2e testing lib, maybe Playwright is the choice. You need also to consider other libraries such as Cypress, with a great community. Puppeteer is a general purpose lib in this context, it’s very flexible with official Google support
  • 18. USE CASE Let’s see how we can use Puppeteer 2
  • 19. Scraping is very useful on PWA, SPA, SSR and can find out vulnerabilities, performance leak, incorrect user journey, etc. A lot of company (e.g. CodeSandbox) started to use Puppeteer internally for testing purpose against their own application. Scraping
  • 20. Apart from libraries such as Cypress, you can use Puppeteer in your pipeline as e2e testing, automated UI testing, visual testing, regression testing, integrate Jest, Mocha or other test frameworks. All in one. Testing
  • 21. Assert that a product is show on the search result page of the Alibaba.com website after typing in the search bar a query name Example
  • 22. Using the DevTools protocol comes with advangetes such as verifying the code coverage for our JS and CSS, testing out some UI/UX feature such as a lazy loading feature or just speed up a keyboard input process Development utility
  • 25. The reason: I needed a vacation Code available github.com/theJoin95/skyscanner-flights-scraping Project goals: - Create a private API layer to search flights - Create a cron script to scrape and check the flights - Create a CLI to check flights manually - Get the cheapest flight to Oporto (Portugal) from Italy and enjoy SkyScanner Scraper
  • 28. Code available on: github.com/schrodinger-Hat/youtube-to- anchorfm/ As a podcaster, via Schrodinger Hat, we were streaming on YouTube and Twitch our podcast episodes. Then, we were manually uploading the audio file on Anchor.fm and published it on any podcast platform Manually. YouTube to Anchor.fm
  • 29. We made a Github Action that take in input the latest video on our YouTube channel and automatically convert it in an audio file, sign in on Anchor.fm, upload the audio file and publish it. Automatically. GitHub Action + NodeJS
  • 31. The end My goal was to inspire you to try to automate a process or activity with these technology (or their alternatives) In my opinion automation, in e2e testing and UI testing, is the key in the development of the modern applications Puppeteer is an open source library on Github. Feel free to contribute!
  • 32. CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, and infographics & images by Freepik Do you have any questions? miki.lombi@gmail.com mikilombardi.com Thanks!
  • 33. CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, and infographics & images by Freepik QA?! Please keep this slide for attribution