SlideShare a Scribd company logo
Drive chrome(headless) with
puppeteer
By Shilpa G
LinkedIn - /gshilpa3
Github - /ShilpaGopal
Browser Instrumentation with DevTools
Chrome DevTool Protocol
The Chrome DevTools Protocol allows for tools to instrument, inspect, debug and
profile. It exposes API to access the Devtool feature.
DevTools Protocol via Chrome extension

Recommended for you

Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test Runner

Playwright Test is a new test runner built from scratch by the Playwright team specifically to accommodate end-to-end testing needs. Join Principal Engineer, Andrey Lushinkov as he demonstrates how to use Playwright Test to author new tests, how to migrate existing tests, how to deploy them on CI, and debug them if something goes wrong.

software testingtest automationplaywright
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...

The document is about a MeetUp event on January 14, 2021 to discuss browser automation using Playwright. It provides an agenda for the event including demonstrations of using Playwright to interact with web applications, scrape data from websites, and expose user interfaces as APIs. It also discusses features of Playwright and opportunities it enables for test automation, data retrieval, health checks, and more. Ethical considerations for relying on user interfaces are mentioned. The document contains several code snippets demonstrating Playwright.

playwrightautomationbrowser
The WebKit project
The WebKit projectThe WebKit project
The WebKit project

The document discusses the WebKit project and how to contribute to it. It describes WebKit as an open source web browser engine used in browsers and other applications. It provides information on WebKit's architecture, goals, features, ports to different platforms, and the WebKit2 API. It also discusses the large WebKit community, how work is tracked, and how developers can contribute through bug fixing, new features, or creating new ports.

webkit web linux opensource linuxcon
DevTools as Protocol client
Sniffing Chrome DevTool Protocol
$ alias google-canary="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome
Canary"
$ google-canary --remote-debugging-port=9222 https://thoughtworks-bangalore.github.io/vodQA/
const WebSocket = require('ws');
var fs = require('fs');
ws = new
WebSocket("ws://localhost:9222/devtools/page/387D2CABAF785990F16940EEF89
BF032");
ws.onopen = function () {
console.log('websocket is connected ...');
ws.send('{"id":1,"method":"Page.enable","params":{}}', (err) => {
if (err) {
console.log(err);
}else{
ws.send('{"id":2,"method":"Page.navigate","params":{"url":"https://www.google.com/
"}}', (err) => {
if (err) {
console.log(err);
}else{
ws.send('{"id":3,"method":"Page.captureScreenshot","params":{}}', (err)
=> {
if (err) {console.log(err);}
});
}
});
}
});
}
ws.onmessage = function (ev) {
response = JSON.parse(ev.data);
if(response.id == 3){const buffer = new Buffer(response.result.data, 'base64');
fs.writeFile("./screenshots/ws_screenshot.png", buffer, function(err) {
if(err) {return console.log(err);}
console.log("The ScreenShot is Captured");
ws.close();
});
}
const puppeteer = require('puppeteer');
puppeteer.launch().then(async browser => {
const page = await browser.newPage();
await page.goto('https://www.google.com/');
await page.screenshot({path:'./screenshots/homePage.png'});
await browser.close();
});
Chrome devtool protocol Puppeteer
Pyramid of Puppeteer
Script

Recommended for you

Cypress-vs-Playwright: Let the Code Speak
Cypress-vs-Playwright: Let the Code SpeakCypress-vs-Playwright: Let the Code Speak
Cypress-vs-Playwright: Let the Code Speak

Hear what the code has to say in this epic matchup between test automation frameworks—Cypress vs. Playwright—and see who will be crowned the winner in this webinar by Applitools See the session materials at https://applitools.info/pmv Rather than compile lists of feature comparisons, this matchup is a battle of the code where Cypress Ambassador Filip Hric and Automation Panda Andrew Knight implement small coding challenges in JavaScript using Cypress and Playwright, respectively. They then compare and contrast their solutions, and the audience chooses the winner. See comparisons of Cypress and Playwright in: API requests Inline frames Alerts Page Objects...and more! From the audience: "This was great. Loved the playful banter." "Event was really well done..fair play to all involved" "Very Useful and Interesting Session"

cypressplaywrighttest automation
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript

Here’s a comprehensive step-by-step tutorial on how to get started with Vue Typescript. Let’s understand building To-do application combining Vue 3 + Typescript.

vue 3vue.jsvue
Why Should we use Microsoft's Playwright
Why Should we use Microsoft's PlaywrightWhy Should we use Microsoft's Playwright
Why Should we use Microsoft's Playwright

Playwright enables fast, reliable and capable testing and automation across all modern browsers. This guide covers those key differentiators to help you decide on the right tool for your automated tests.

web app testingplaywrighttest automation
Puppeteer
npm i puppeteer --save
● Zero configuration
● Bundles latest chromium
● High level API’s for the common use cases
● async/await latest JS features
Puppeteer: launch chromium in headfull
const browser = await puppeteer.launch({
headless: false
});
Puppeteer: launch chrome in headless
const browser = await puppeteer.launch({
headless: true,
executablePath: '/usr/bin/chrome'
});
Optimization: Don’t have to wait for the entire page to load
const url = 'http://automationpractice.com/'
await page.goto(url, {waitUntil: 'domcontentloaded'})
// Resolve When <div id='home_page'> exists in DOM
await page.waitForSelector('#home_page');

Recommended for you

Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes

- jQuery is a JavaScript library that simplifies HTML document traversal and manipulation, as well as event handling, animation, and Ajax. - It works by allowing the selection of HTML elements and running functions on those elements via a simple and consistent API. - Common uses of jQuery include modifying HTML content, CSS styling, handling user events, animating elements, and loading data from web servers via Ajax.

Playwright Begginers Presentation
Playwright Begginers PresentationPlaywright Begginers Presentation
Playwright Begginers Presentation

This is a quick Presentation of the basic features of Playwright, a light-weight E2E testing framework

testingsoftware testingprogramming
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript

Over 200 Pages of resources and code snippets to learn JavaScript and JavaScript DOM manipulation. JavaScript is the most popular web programming language and this eBook will help you learn more about JavaScript Coding

javascriptcodingweb
Optimization: Abort unnecessary requests
// 1. Intercept network requests.
await page.setRequestInterception(true);
page.on('request', interceptedRequest => {
// 2. Ignore requests for resources that don't produce DOM
const whitelist = ['document', 'script', 'xhr', 'fetch'];
if (!whitelist.includes(interceptedRequest.resourceType()))
interceptedRequest.abort();
else
// 3. Pass through all other requests.
interceptedRequest.continue();
});
await page.goto('http://automationpractice.com/');
Puppeteer - Handling HTTP Basic Authentication
{
"id": 2,
"method": "Network.setExtraHTTPHeaders",
"params": {
"headers": {
"Authorization": "Basic
YWRtaW46YWRtaW4="
}
}
}
Websocket JSON request
Puppeteer: Network Emulation
{
"id": 7,
"method": "Network.emulateNetworkConditions",
"params": {
"offline": true,
"latency": 300,
"downloadThroughput": 250,
"uploadThroughput": 750
}
}
Websocket JSON request
Puppeteer: Mock Geo-Location
{
"id": 3,
"method": "Emulation.setGeolocationOverride",
"params": {
"latitude": 27.1752868,
"longitude": 78.040009,
"accuracy": 100
}
}
Websocket JSON request

Recommended for you

Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup

Flask is a micro web development framework for Python that keeps its core simple but allows for extensibility. It emphasizes building applications with extensions rather than having all functionality contained within the framework. A minimal Flask app requires only a few lines of code and runs a development server. Templates can be rendered to generate dynamic HTML content by passing context through the render_template function. Flask supports common features like request handling, cookies, sessions, and file uploads through extensions.

flaskpythonweb design and development
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS app

This document discusses testing React JS applications with tools like Mocha, Enzyme, and Webdriver.io. It covers why writing tests is important, provides examples of unit testing React components with Enzyme, and discusses how to do functional and integration testing with Webdriver.io. The document demonstrates testing architectures, common testing patterns like page objects, and concludes that frontend tests are important and not too costly to implement.

reactjstestingreact
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해

스프링 시큐리티의 주요 구성 요소인 SecurityFilterChain, AuthenticationManager, SecurityInterceptor의 구조 소개

authenticationmanager스프링 시큐리티securityfilterchain
Puppeteer: Make your browser talk
Puppeteer examples
● Scrap link from website
● Device emulation - Keyboard API
● Capture performance data
● Capture timeline trace
● Testing Offline
● Create pdf of the website
● A/B testing
Can my existing tests suit
in selenium take advantage
of chrome Devtools???
Selenium + Chrome Driver
Selenium is controlling the browser, no other client can debug it

Recommended for you

Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing

Technical presentation given by Laurent Duveau at the Angular Vancouver Meetup on June 07, 2018. https://www.meetup.com/vanangular/events/250883030/

angularjavascriptweb development
Puppeteer can automate that! - AmsterdamJS
Puppeteer can automate that! - AmsterdamJSPuppeteer can automate that! - AmsterdamJS
Puppeteer can automate that! - AmsterdamJS

Puppeteer is a node library which provides a high-level API to control Chrome over the DevTools Protocol. When combined with the power of the web technologies, it can be used for automating image processing and batch file generation, creating automated visual testing with device emulation, tracking page loading performance, enforcing performance and code coverage budgets on CI, crawling a SPA, capturing a timeline trace of your site to help diagnose performance issues and more! We'll explore those capabilities of Puppeteer API with combination of DevTools protocol and cloud functions (FaaS) with a showcase of real life use cases demonstrated by live-examples. Finally, we’ll go through the existing puppeteer based SaaS solutions such as Checkly and Browserless.

blinkcdpchrome
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)

The Browser Object Model (BOM) in JavaScript includes the properties and methods for JavaScript to interact with the web browser. BOM provides you with window object, for example, to show the width and height of the window. It also includes the window.screen object to show the width and height of the screen.

javascriptwebstack academy bangalorefullstack web developer
Multi-client remote debugging support
Selenium + ChromeDriver + DevTools
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY,
System.getProperty("user.dir") + "/target/chromedriver.log");
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY,
System.getProperty("user.dir") + "/driver/chromedriver.exe");
ChromeDriverService service = new ChromeDriverService.Builder()
.usingAnyFreePort()
.withVerbose(true)
.build();
service.start();
Selenium + ChromeDriver + DevTools
Launch chrome browser using ChromeDriverService, to parse ChromeDriver logs
Extract the websocketDebuggerUrl using which the browser instance is instrumented
Conclusion
RemoteDebug
RemoteDebug is an initiative to bring a common
remote debugging protocol to today's browsers.
The vision is to enable a new generation of
DevTools and editors that are able to
communicate independently of their vendor.
- By Kenneth Auchenberg

Recommended for you

Service workers
Service workersService workers
Service workers

Service Workers is coming. Bring your own magic with the first programmable cache in your script, and more! Presented at the GDG Korea DevFest 2014 on the 31st of May 2014: https://sites.google.com/site/gdgdevfestkorea2014/

gdg devfestservice worker
Javascript basics
Javascript basicsJavascript basics
Javascript basics

This document provides an overview of JavaScript basics including variables, data types, operators, conditional statements, loops, functions, arrays, and error handling. It explains JavaScript syntax, how to include JavaScript code in HTML pages, and commonly used statements like if/else, switch case, while and for loops. It also covers JavaScript functions, returning values from functions, and printing pages. The document describes JavaScript strings and array objects, and their associated methods. Finally, it discusses different types of errors in JavaScript like syntax errors, runtime errors, and logical errors.

02 banking trojans-thomassiebert
02 banking trojans-thomassiebert02 banking trojans-thomassiebert
02 banking trojans-thomassiebert

This document discusses advanced techniques used in modern banking trojans. It describes how trojans operate by hijacking browsers using techniques like hooking browser APIs and modifying encrypted network traffic. It also discusses how trojans evade detection from tools like BankGuard and how their command and control structures have evolved to use peer-to-peer and Tor networks.

Conclusion
Chrome Debugging Protocol has unlocked possibility to automate web
application using devtool protocol.
Puppeteer is making our life easy by providing High level API to write highly
reliable tests and perform network throttling, device emulation etc.
Reference
https://github.com/transitive-bullshit/awesome-puppeteer
https://github.com/dhamaniasad/HeadlessBrowsers
https://developers.google.com/web/updates/2017/04/headless-chrome
https://developers.google.com/web/tools/puppeteer/
https://github.com/checkly/puppeteer-recorder
https://github.com/ShilpaGopal/puppeteer-examples-vodqa
https://github.com/sahajamit/chrome-devtools-webdriver-integration
Try Puppeteer online : https://try-puppeteer.appspot.com/
Puppeteer documentation : https://pptr.dev/
THANK YOU

More Related Content

What's hot

Puppeteer can automate that! - Frontmania
Puppeteer can automate that! - FrontmaniaPuppeteer can automate that! - Frontmania
Puppeteer can automate that! - Frontmania
Önder Ceylan
 
No drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwrightNo drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwright
Mastacheata1
 
Cypress-vs-Playwright-Rematch-Applitools.pdf
Cypress-vs-Playwright-Rematch-Applitools.pdfCypress-vs-Playwright-Rematch-Applitools.pdf
Cypress-vs-Playwright-Rematch-Applitools.pdf
Applitools
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test Runner
Applitools
 
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Lucas Jellema
 
The WebKit project
The WebKit projectThe WebKit project
The WebKit project
juanjosanchezpenas
 
Cypress-vs-Playwright: Let the Code Speak
Cypress-vs-Playwright: Let the Code SpeakCypress-vs-Playwright: Let the Code Speak
Cypress-vs-Playwright: Let the Code Speak
Applitools
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
Katy Slemon
 
Why Should we use Microsoft's Playwright
Why Should we use Microsoft's PlaywrightWhy Should we use Microsoft's Playwright
Why Should we use Microsoft's Playwright
Knoldus Inc.
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
Simon Willison
 
Playwright Begginers Presentation
Playwright Begginers PresentationPlaywright Begginers Presentation
Playwright Begginers Presentation
FranPerea6
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
Laurence Svekis ✔
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
Areski Belaid
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS app
Aleks Zinevych
 
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해
beom kyun choi
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
Laurent Duveau
 
Puppeteer can automate that! - AmsterdamJS
Puppeteer can automate that! - AmsterdamJSPuppeteer can automate that! - AmsterdamJS
Puppeteer can automate that! - AmsterdamJS
Önder Ceylan
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
Service workers
Service workersService workers
Service workers
jungkees
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
shreesenthil
 

What's hot (20)

Puppeteer can automate that! - Frontmania
Puppeteer can automate that! - FrontmaniaPuppeteer can automate that! - Frontmania
Puppeteer can automate that! - Frontmania
 
No drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwrightNo drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwright
 
Cypress-vs-Playwright-Rematch-Applitools.pdf
Cypress-vs-Playwright-Rematch-Applitools.pdfCypress-vs-Playwright-Rematch-Applitools.pdf
Cypress-vs-Playwright-Rematch-Applitools.pdf
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test Runner
 
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
 
The WebKit project
The WebKit projectThe WebKit project
The WebKit project
 
Cypress-vs-Playwright: Let the Code Speak
Cypress-vs-Playwright: Let the Code SpeakCypress-vs-Playwright: Let the Code Speak
Cypress-vs-Playwright: Let the Code Speak
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
 
Why Should we use Microsoft's Playwright
Why Should we use Microsoft's PlaywrightWhy Should we use Microsoft's Playwright
Why Should we use Microsoft's Playwright
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Playwright Begginers Presentation
Playwright Begginers PresentationPlaywright Begginers Presentation
Playwright Begginers Presentation
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS app
 
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Puppeteer can automate that! - AmsterdamJS
Puppeteer can automate that! - AmsterdamJSPuppeteer can automate that! - AmsterdamJS
Puppeteer can automate that! - AmsterdamJS
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
Service workers
Service workersService workers
Service workers
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 

Similar to Drive chrome(headless) with puppeteer

02 banking trojans-thomassiebert
02 banking trojans-thomassiebert02 banking trojans-thomassiebert
02 banking trojans-thomassiebert
geeksec80
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
Caesar Chi
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
iMasters
 
iMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within MicroservicesiMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within Microservices
Erick Belluci Tedeschi
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
Sergi Almar i Graupera
 
Romulus OWASP
Romulus OWASPRomulus OWASP
Romulus OWASP
Grupo Gesfor I+D+i
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.js
Timur Shemsedinov
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
Matt Raible
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Web Standards Support in WebKit
Web Standards Support in WebKitWeb Standards Support in WebKit
Web Standards Support in WebKit
Joone Hur
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
Gonzalo Ayuso
 
DevSum'15 : Microsoft Azure and Things
DevSum'15 : Microsoft Azure and ThingsDevSum'15 : Microsoft Azure and Things
DevSum'15 : Microsoft Azure and Things
Thomas Conté
 
Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)
Kazuaki Matsuo
 
Nk API - examples
Nk API - examplesNk API - examples
Nk API - examples
nasza-klasa
 
5.node js
5.node js5.node js
5.node js
Geunhyung Kim
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
Ohad Kravchick
 
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 201910 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
Matt Raible
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar
 

Similar to Drive chrome(headless) with puppeteer (20)

02 banking trojans-thomassiebert
02 banking trojans-thomassiebert02 banking trojans-thomassiebert
02 banking trojans-thomassiebert
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
 
iMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within MicroservicesiMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within Microservices
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
 
Romulus OWASP
Romulus OWASPRomulus OWASP
Romulus OWASP
 
FwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.jsFwDays 2021: Metarhia Technology Stack for Node.js
FwDays 2021: Metarhia Technology Stack for Node.js
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Web Standards Support in WebKit
Web Standards Support in WebKitWeb Standards Support in WebKit
Web Standards Support in WebKit
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
DevSum'15 : Microsoft Azure and Things
DevSum'15 : Microsoft Azure and ThingsDevSum'15 : Microsoft Azure and Things
DevSum'15 : Microsoft Azure and Things
 
Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)Chrome Devtools Protocol via Selenium/Appium (English)
Chrome Devtools Protocol via Selenium/Appium (English)
 
Nk API - examples
Nk API - examplesNk API - examples
Nk API - examples
 
5.node js
5.node js5.node js
5.node js
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 201910 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
10 Excellent Ways to Secure Your Spring Boot Application - Devoxx Belgium 2019
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 

More from VodqaBLR

Consumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTConsumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACT
VodqaBLR
 
Taiko presentation
Taiko presentationTaiko presentation
Taiko presentation
VodqaBLR
 
Chatbot Testing
Chatbot TestingChatbot Testing
Chatbot Testing
VodqaBLR
 
Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018
VodqaBLR
 
Android security testing
Android security testingAndroid security testing
Android security testing
VodqaBLR
 
Advance appium workshop.pptx
Advance appium workshop.pptxAdvance appium workshop.pptx
Advance appium workshop.pptx
VodqaBLR
 
Blockchain workshop
Blockchain workshopBlockchain workshop
Blockchain workshop
VodqaBLR
 
Testing natural language processing
Testing natural language processingTesting natural language processing
Testing natural language processing
VodqaBLR
 
Improve your Chaos IQ
Improve your Chaos IQImprove your Chaos IQ
Improve your Chaos IQ
VodqaBLR
 
WebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable TestWebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable Test
VodqaBLR
 
Testing Tools with AI
Testing Tools with AITesting Tools with AI
Testing Tools with AI
VodqaBLR
 
Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.
VodqaBLR
 
Visual testing for Mobile Native Applications
Visual testing for Mobile Native ApplicationsVisual testing for Mobile Native Applications
Visual testing for Mobile Native Applications
VodqaBLR
 
Parallel Sim Test using XCUI
Parallel Sim Test using XCUI Parallel Sim Test using XCUI
Parallel Sim Test using XCUI
VodqaBLR
 
Performance Testing using Taurus
Performance Testing using TaurusPerformance Testing using Taurus
Performance Testing using Taurus
VodqaBLR
 
Writing Maintainable Tests
Writing Maintainable TestsWriting Maintainable Tests
Writing Maintainable Tests
VodqaBLR
 
Continuous security testing - sharing responsibility
Continuous security testing - sharing responsibilityContinuous security testing - sharing responsibility
Continuous security testing - sharing responsibility
VodqaBLR
 
ABCing docker with environments - workshop
ABCing docker with environments - workshopABCing docker with environments - workshop
ABCing docker with environments - workshop
VodqaBLR
 
Automate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMaticAutomate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMatic
VodqaBLR
 
Quality Assurance in Healthcare
Quality Assurance in HealthcareQuality Assurance in Healthcare
Quality Assurance in Healthcare
VodqaBLR
 

More from VodqaBLR (20)

Consumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTConsumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACT
 
Taiko presentation
Taiko presentationTaiko presentation
Taiko presentation
 
Chatbot Testing
Chatbot TestingChatbot Testing
Chatbot Testing
 
Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018
 
Android security testing
Android security testingAndroid security testing
Android security testing
 
Advance appium workshop.pptx
Advance appium workshop.pptxAdvance appium workshop.pptx
Advance appium workshop.pptx
 
Blockchain workshop
Blockchain workshopBlockchain workshop
Blockchain workshop
 
Testing natural language processing
Testing natural language processingTesting natural language processing
Testing natural language processing
 
Improve your Chaos IQ
Improve your Chaos IQImprove your Chaos IQ
Improve your Chaos IQ
 
WebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable TestWebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable Test
 
Testing Tools with AI
Testing Tools with AITesting Tools with AI
Testing Tools with AI
 
Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.
 
Visual testing for Mobile Native Applications
Visual testing for Mobile Native ApplicationsVisual testing for Mobile Native Applications
Visual testing for Mobile Native Applications
 
Parallel Sim Test using XCUI
Parallel Sim Test using XCUI Parallel Sim Test using XCUI
Parallel Sim Test using XCUI
 
Performance Testing using Taurus
Performance Testing using TaurusPerformance Testing using Taurus
Performance Testing using Taurus
 
Writing Maintainable Tests
Writing Maintainable TestsWriting Maintainable Tests
Writing Maintainable Tests
 
Continuous security testing - sharing responsibility
Continuous security testing - sharing responsibilityContinuous security testing - sharing responsibility
Continuous security testing - sharing responsibility
 
ABCing docker with environments - workshop
ABCing docker with environments - workshopABCing docker with environments - workshop
ABCing docker with environments - workshop
 
Automate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMaticAutomate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMatic
 
Quality Assurance in Healthcare
Quality Assurance in HealthcareQuality Assurance in Healthcare
Quality Assurance in Healthcare
 

Recently uploaded

Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Asher Sterkin
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
karim wahed
 
dachnug51 - Whats new in domino 14 .pdf
dachnug51 - Whats new in domino 14  .pdfdachnug51 - Whats new in domino 14  .pdf
dachnug51 - Whats new in domino 14 .pdf
DNUG e.V.
 
Attendance Tracking From Paper To Digital
Attendance Tracking From Paper To DigitalAttendance Tracking From Paper To Digital
Attendance Tracking From Paper To Digital
Task Tracker
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
Roshan Dwivedi
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Livetecs LLC
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
taskroupseo
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
AUGNYC
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
confluent
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
Severalnines
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
Ortus Solutions, Corp
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
SimonedeGijt
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Sparity1
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Trackobit
 
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
bhatinidhi2001
 
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdfWhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
onemonitarsoftware
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
908dutch
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 

Recently uploaded (20)

Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
 
dachnug51 - Whats new in domino 14 .pdf
dachnug51 - Whats new in domino 14  .pdfdachnug51 - Whats new in domino 14  .pdf
dachnug51 - Whats new in domino 14 .pdf
 
Attendance Tracking From Paper To Digital
Attendance Tracking From Paper To DigitalAttendance Tracking From Paper To Digital
Attendance Tracking From Paper To Digital
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
 
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.CViewSurvey Digitech Pvt Ltd that  works on a proven C.A.A.G. model.
CViewSurvey Digitech Pvt Ltd that works on a proven C.A.A.G. model.
 
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdfWhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
 
Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 

Drive chrome(headless) with puppeteer

  • 1. Drive chrome(headless) with puppeteer By Shilpa G LinkedIn - /gshilpa3 Github - /ShilpaGopal
  • 3. Chrome DevTool Protocol The Chrome DevTools Protocol allows for tools to instrument, inspect, debug and profile. It exposes API to access the Devtool feature.
  • 4. DevTools Protocol via Chrome extension
  • 6. Sniffing Chrome DevTool Protocol $ alias google-canary="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" $ google-canary --remote-debugging-port=9222 https://thoughtworks-bangalore.github.io/vodQA/
  • 7. const WebSocket = require('ws'); var fs = require('fs'); ws = new WebSocket("ws://localhost:9222/devtools/page/387D2CABAF785990F16940EEF89 BF032"); ws.onopen = function () { console.log('websocket is connected ...'); ws.send('{"id":1,"method":"Page.enable","params":{}}', (err) => { if (err) { console.log(err); }else{ ws.send('{"id":2,"method":"Page.navigate","params":{"url":"https://www.google.com/ "}}', (err) => { if (err) { console.log(err); }else{ ws.send('{"id":3,"method":"Page.captureScreenshot","params":{}}', (err) => { if (err) {console.log(err);} }); } }); } }); } ws.onmessage = function (ev) { response = JSON.parse(ev.data); if(response.id == 3){const buffer = new Buffer(response.result.data, 'base64'); fs.writeFile("./screenshots/ws_screenshot.png", buffer, function(err) { if(err) {return console.log(err);} console.log("The ScreenShot is Captured"); ws.close(); }); } const puppeteer = require('puppeteer'); puppeteer.launch().then(async browser => { const page = await browser.newPage(); await page.goto('https://www.google.com/'); await page.screenshot({path:'./screenshots/homePage.png'}); await browser.close(); }); Chrome devtool protocol Puppeteer
  • 9. Puppeteer npm i puppeteer --save ● Zero configuration ● Bundles latest chromium ● High level API’s for the common use cases ● async/await latest JS features
  • 10. Puppeteer: launch chromium in headfull const browser = await puppeteer.launch({ headless: false });
  • 11. Puppeteer: launch chrome in headless const browser = await puppeteer.launch({ headless: true, executablePath: '/usr/bin/chrome' });
  • 12. Optimization: Don’t have to wait for the entire page to load const url = 'http://automationpractice.com/' await page.goto(url, {waitUntil: 'domcontentloaded'}) // Resolve When <div id='home_page'> exists in DOM await page.waitForSelector('#home_page');
  • 13. Optimization: Abort unnecessary requests // 1. Intercept network requests. await page.setRequestInterception(true); page.on('request', interceptedRequest => { // 2. Ignore requests for resources that don't produce DOM const whitelist = ['document', 'script', 'xhr', 'fetch']; if (!whitelist.includes(interceptedRequest.resourceType())) interceptedRequest.abort(); else // 3. Pass through all other requests. interceptedRequest.continue(); }); await page.goto('http://automationpractice.com/');
  • 14. Puppeteer - Handling HTTP Basic Authentication { "id": 2, "method": "Network.setExtraHTTPHeaders", "params": { "headers": { "Authorization": "Basic YWRtaW46YWRtaW4=" } } } Websocket JSON request
  • 15. Puppeteer: Network Emulation { "id": 7, "method": "Network.emulateNetworkConditions", "params": { "offline": true, "latency": 300, "downloadThroughput": 250, "uploadThroughput": 750 } } Websocket JSON request
  • 16. Puppeteer: Mock Geo-Location { "id": 3, "method": "Emulation.setGeolocationOverride", "params": { "latitude": 27.1752868, "longitude": 78.040009, "accuracy": 100 } } Websocket JSON request
  • 17. Puppeteer: Make your browser talk
  • 18. Puppeteer examples ● Scrap link from website ● Device emulation - Keyboard API ● Capture performance data ● Capture timeline trace ● Testing Offline ● Create pdf of the website ● A/B testing
  • 19. Can my existing tests suit in selenium take advantage of chrome Devtools???
  • 20. Selenium + Chrome Driver Selenium is controlling the browser, no other client can debug it
  • 22. Selenium + ChromeDriver + DevTools System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, System.getProperty("user.dir") + "/target/chromedriver.log"); System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, System.getProperty("user.dir") + "/driver/chromedriver.exe"); ChromeDriverService service = new ChromeDriverService.Builder() .usingAnyFreePort() .withVerbose(true) .build(); service.start();
  • 23. Selenium + ChromeDriver + DevTools Launch chrome browser using ChromeDriverService, to parse ChromeDriver logs Extract the websocketDebuggerUrl using which the browser instance is instrumented
  • 24. Conclusion RemoteDebug RemoteDebug is an initiative to bring a common remote debugging protocol to today's browsers. The vision is to enable a new generation of DevTools and editors that are able to communicate independently of their vendor. - By Kenneth Auchenberg
  • 25. Conclusion Chrome Debugging Protocol has unlocked possibility to automate web application using devtool protocol. Puppeteer is making our life easy by providing High level API to write highly reliable tests and perform network throttling, device emulation etc.

Editor's Notes

  1. Over the past decade, hundreds of new frameworks have evolved to support powerful Javascript based web apps. These frameworks have resulted in interactive UI, impressive styling components without compromising the speed heavily. These frameworks have eased the life of hundreds of people to build complicated, features like live location tracking,conversational UI, IoT rtc . it has taken a toll on the testers. Where we are still figuring out to bypass basic auth programatically, how can i mock the location, how to make my browser speak. This has resulted in sophisticated and flaky UI automation scripts with selenium. Among all Selenium alternatives the most interesting emerging ones are tools developed around Google Chrome DevTools Protocol. And the most prominent one is Puppeteer. In today talk will see how we can automate some of those features using puppeter and how it is build over Chrome devtool protol In order to achieve this programmatically, with the existing solutions we end up writing sophisticated and flaky UI automation scripts . But we need a tool which will help us to automate all the browser supported features. Among the interesting and emerging ones , tools that are built on google’s chrome devtools protocol, unlocks the possibility to write automation script for some of those features.
  2. The DevTools UI is a web application embedded inside Chrome. Every browser has debugger in it. These debuggers exposes API to perform actions on browser using devtool. Devtools has plenty of options like you make chnages to dom/css and and see the live update, you can monitor the network calls, you csn simulator different networks, debug the javascript, add profiles and much more , These are nothing but we are instrumenting the browser. Instrumentation is divided into a number of domains (DOM, Debugger, Network etc.). Each domain defines a number of commands it supports and events it generates. Now the question would be can we use devtool to automate browser supported features????
  3. That means you can access those domain using chrome devtool protocol. There are two ways to instrument the browser using chrome devtool protocol,
  4. We can create chrome extension using chrome.debugger extension API that exposes this websocket JSON message transport interface. Along with getting control over remotely running chrome instance, we can also instrument it using same extensions. Most of the Web-based IDE’s are built taking advantage of the Chrome Debugger Extension API. visual studios, westrome, online front end web editing tools like vewjs
  5. You can attach The Developer Tools front-end to a remotely running Chrome instance for debugging. For this scenario to work, you should start your hostChrome instance with the remote-debugging-port. Now you can navigate to the given port from your client and attach to any of the discovered tabs for debugging: http://localhost:9222 When you navigate your client browser to the remote's Chrome port, Developer Tools front-end is being served from the host Chrome as a Web Application from the Web Server. It fetches HTML, JavaScript and CSS files over HTTP Once loaded, Developer Tools establishes a Web Socket connection to its host and starts exchanging JSON messages with it. In this scenario, you can substitute Developer Tools front-end with your own implementation. Instead of navigating to the HTML page at http://localhost:9222, your application can discover available pages by requesting: http://localhost:9222/json and getting a JSON object with information about inspectable pages along with the WebSocket addresses that you could use in order to start instrumenting them.
  6. Data exchange on the socket. Websockets are nothing but JSOn based two way communication channel between server and client. With this websocket API client can send message s to the server , and recieve event based response.
  7. We got the headless chrome, CDP that is chrome devtool protocol where you can do all the stuffs that you do it on the browser. On top of that lies the puppeteer which exposes high level API of CDP.
  8. It's node Library for headless chrome/chromium, It provides high level API for the devtool protocol so that it's easy to automate and some of the powerful things we can do in the browser. async/ await function of javascript actually plays a vital role in eliminating wait for present. They provide implicit for for every action through the promisises, So we dont have to write thread.sleep any where. Puppeteer has event-driven architecture, which removes a lot of potential flakiness. There’s no need for evil “sleep(1000)” calls in puppeteer scripts. Puppeteer runs headless by default, which makes it fast to run. Puppeteer v1.5.0 also exposes browser contexts, making it possible to efficiently parallelize test execution.
  9. To understand the awesomeness of Puppeteer. Lets take a look at some of the optimization we can do on our code. The DOMContentLoaded event is fired when the document has been completelyloaded and parsed, without waiting for stylesheets, images, and subframes to finishloading (the load event can be used to detect a fully-loaded page). Most power full API for locating element is page.waitForSelector
  10. We need to use Authorization header. It will check whether the network interception is set then adds the Autorization header with basic auth.
  11. Sometimes it is very handy to see how our web application works in offline mode or in fluctuating network. Here is the message:
  12. The Web Speech API adds voice recognition (speech to text) and speech synthesis (text to speech) to JavaScript.
  13. As of Chrome 63, DevTools now supports multiple remote debugging clients by default
  14. Let’s go little deeper in to this Chrome’s remote debugging protocol. This chrome dev-tools web-socket api gives you capability to control any local or remote browser but till Chrome version 62 only one client can connect to this interface, which means when selenium is controlling the browser, no other client can debug it.
  15. Chrome Extensions using the chrome.debugger API can now run at the same time as DevTools. Multiple different Chrome Extensions can now use the chrome.debugger API on the same tab simultaneously. Two separate WebSocket protocol clients, such as Puppeteer or chrome-remote-interface, can now connect to the same tab simultaneously. Let’s go little deeper in to this Chrome’s remote debugging protocol. This chrome dev-tools web-socket api gives you capability to control any local or remote browser but till Chrome version 62 only one client can connect to this interface, which means when selenium is controlling the browser, no other client can debug it. From chrome 63 which will be released on 5th December 2017, we can have multiple clients connected to chrome and debug it.
  16. Now we can connect to this websocket url using any any java library of our choice. I used this one (nv-websocket-client).
  17. Launching a Chrome browser using ChromeDriverService as we would need to parse some chromedriver logs to get the port on which the remote debugger is running.
  18. edge-diagnostics-adapter Fire fox Valence remotedebug-ios-webkit-adapter https://github.com/square/PonyDebugger to Chrome DevTools use debug native iOS applications. Stetho, a bridge that enables developers to debug their native Android apps using Chrome DevTools.
  19. What are we waiting for let's use CDP to automate.
  20. Before I wrap up I need to give credit to the awesome work done on puppeteer. These are some of link which I referred. Examples that i used you can find that in git hub repo.