SlideShare a Scribd company logo
1 of 15
PWA automation with
Puppeteer
Pankaj Ladhar
Agenda
● What is PWA ?
● What is Puppeteer ?
● Getting started with Puppeteer
● More in Puppeteer ?
● Demo
● Resources
What is PWA
(Progressive Web Apps) ?
What is PWA ?
What is PWA ?
A PWA is not an API or
a technology, but it is a
web development
approach that uses a
combination of tools and
technologies already
available to create
targeted, ideal user
experiences.
What is Service Worker ?
What is Puppeteer ?
● Modern Node library for
headless Chrome/Chromium
● Supports ES6 features
● Zero config Bundles latest
Chromium
npm install puppeteer
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto
("https://pankajladhar.github.io/speedy-math/#/");
await browser.close();
})();
const viewPort = { width: 400, height: 600 };
await puppeteer.launch({
headless: false,
devtools: true
defaultViewport: null,
args: [`--window-size=${viewPort.width},
${viewPort.height}`],
executablePath: "path/local/installed/chrome"
})
(async () => {
...
await page.evaluate("navigator.serviceWorker.ready");
console.log("Going offline");
await page.setOfflineMode(true);
await page.reload({ waitUntil: "networkidle0" });
const text = await page.$eval(".Offline-Banner",
el => el.innerText);
// You are offline.You might see different experience :)!
})();
(async () => {
...
// Returns true if response served from memory or disk cache
page.on('response', r=> r.fromCache());
// Returns true if response served from serviceworker
page.on('response', r=> r.fromServiceWorker());
...
})();
Demo
What else you can achieve using 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.
Resources
● https://developers.google.com/web/tools/puppeteer
● https://pptr.dev/
● https://developers.google.com/web/progressive-web-apps
● https://medium.com/dev-channel/testing-service-workers-318d7b016b19
● Demo source code
Thanks

More Related Content

More from vodQA

More from vodQA (20)

vodQA Pune (2019) - Augmented reality overview and testing challenges
vodQA Pune (2019) - Augmented reality overview and testing challengesvodQA Pune (2019) - Augmented reality overview and testing challenges
vodQA Pune (2019) - Augmented reality overview and testing challenges
 
vodQA Pune (2019) - Testing AI,ML applications
vodQA Pune (2019) - Testing AI,ML applicationsvodQA Pune (2019) - Testing AI,ML applications
vodQA Pune (2019) - Testing AI,ML applications
 
vodQA Pune (2019) - Design patterns in test automation
vodQA Pune (2019) - Design patterns in test automationvodQA Pune (2019) - Design patterns in test automation
vodQA Pune (2019) - Design patterns in test automation
 
vodQA Pune (2019) - Testing ethereum smart contracts
vodQA Pune (2019) - Testing ethereum smart contractsvodQA Pune (2019) - Testing ethereum smart contracts
vodQA Pune (2019) - Testing ethereum smart contracts
 
vodQA Pune (2019) - Insights into big data testing
vodQA Pune (2019) - Insights into big data testingvodQA Pune (2019) - Insights into big data testing
vodQA Pune (2019) - Insights into big data testing
 
vodQA Pune (2019) - Performance testing cloud deployments
vodQA Pune (2019) - Performance testing cloud deploymentsvodQA Pune (2019) - Performance testing cloud deployments
vodQA Pune (2019) - Performance testing cloud deployments
 
vodQA Pune (2019) - Jenkins pipeline As code
vodQA Pune (2019) - Jenkins pipeline As codevodQA Pune (2019) - Jenkins pipeline As code
vodQA Pune (2019) - Jenkins pipeline As code
 
vodQA(Pune) 2018 - Consumer driven contract testing using pact
vodQA(Pune) 2018 - Consumer driven contract testing using pactvodQA(Pune) 2018 - Consumer driven contract testing using pact
vodQA(Pune) 2018 - Consumer driven contract testing using pact
 
vodQA(Pune) 2018 - Visual testing of web apps in headless environment manis...
vodQA(Pune) 2018 - Visual testing of web apps in headless environment   manis...vodQA(Pune) 2018 - Visual testing of web apps in headless environment   manis...
vodQA(Pune) 2018 - Visual testing of web apps in headless environment manis...
 
vodQA(Pune) 2018 - Enhancing the capabilities of testing team preparing for...
vodQA(Pune) 2018 - Enhancing the capabilities of testing team   preparing for...vodQA(Pune) 2018 - Enhancing the capabilities of testing team   preparing for...
vodQA(Pune) 2018 - Enhancing the capabilities of testing team preparing for...
 
vodQA(Pune) 2018 - QAing the security way
vodQA(Pune) 2018 - QAing the security wayvodQA(Pune) 2018 - QAing the security way
vodQA(Pune) 2018 - QAing the security way
 
vodQA(Pune) 2018 - Docker in Testing
vodQA(Pune) 2018 - Docker in TestingvodQA(Pune) 2018 - Docker in Testing
vodQA(Pune) 2018 - Docker in Testing
 
Mobile automation using appium.pptx
Mobile automation using appium.pptxMobile automation using appium.pptx
Mobile automation using appium.pptx
 
An approach to app security - For beginners
An approach to app security - For beginnersAn approach to app security - For beginners
An approach to app security - For beginners
 
Retrospective
RetrospectiveRetrospective
Retrospective
 
Whys and Hows of Automation
Whys and Hows of AutomationWhys and Hows of Automation
Whys and Hows of Automation
 
Test Automation Pyramid
Test Automation PyramidTest Automation Pyramid
Test Automation Pyramid
 
Test automation Frame Works
Test automation Frame WorksTest automation Frame Works
Test automation Frame Works
 
Stand up
Stand upStand up
Stand up
 
Patterns & Anti Patterns of Stand up
Patterns & Anti Patterns of Stand upPatterns & Anti Patterns of Stand up
Patterns & Anti Patterns of Stand up
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

vodQA Bangalore 2019 - PWA automation with puppeteer

  • 2. Agenda ● What is PWA ? ● What is Puppeteer ? ● Getting started with Puppeteer ● More in Puppeteer ? ● Demo ● Resources
  • 5. What is PWA ? A PWA is not an API or a technology, but it is a web development approach that uses a combination of tools and technologies already available to create targeted, ideal user experiences.
  • 6. What is Service Worker ?
  • 7. What is Puppeteer ? ● Modern Node library for headless Chrome/Chromium ● Supports ES6 features ● Zero config Bundles latest Chromium npm install puppeteer
  • 8. const puppeteer = require("puppeteer"); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto ("https://pankajladhar.github.io/speedy-math/#/"); await browser.close(); })();
  • 9. const viewPort = { width: 400, height: 600 }; await puppeteer.launch({ headless: false, devtools: true defaultViewport: null, args: [`--window-size=${viewPort.width}, ${viewPort.height}`], executablePath: "path/local/installed/chrome" })
  • 10. (async () => { ... await page.evaluate("navigator.serviceWorker.ready"); console.log("Going offline"); await page.setOfflineMode(true); await page.reload({ waitUntil: "networkidle0" }); const text = await page.$eval(".Offline-Banner", el => el.innerText); // You are offline.You might see different experience :)! })();
  • 11. (async () => { ... // Returns true if response served from memory or disk cache page.on('response', r=> r.fromCache()); // Returns true if response served from serviceworker page.on('response', r=> r.fromServiceWorker()); ... })();
  • 12. Demo
  • 13. What else you can achieve using 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.
  • 14. Resources ● https://developers.google.com/web/tools/puppeteer ● https://pptr.dev/ ● https://developers.google.com/web/progressive-web-apps ● https://medium.com/dev-channel/testing-service-workers-318d7b016b19 ● Demo source code

Editor's Notes

  1. Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium.