SlideShare a Scribd company logo
1 of 31
Download to read offline
BROWSER AUTOMATION USING
DEVTOOLS
VODQA Pune 2019
By :
Shilpa G
QA at ThoughtWorks
LinkedIn - /gshilpa3
Github - /Shilpagopal
WHY
DEVTOOLS?
Limitation of existing tools to automate all
the browser supported features.
■ Handling HTTP basic authentications
■ Getting events from browser
■ Setting fake geo location
■ Updating User-agent
■ Interception web responses
■ Network Simulation
■ Screen casting chrome session
Chrome Devtools unlocks the possibility
to automate most of the browser
supported features.
2
“We can’t solve
our problems with
the same thinking
we used when we
created them” -
Albert Einstein
BROWSER INSTRUMENTATION WITH DEVTOOLS
3
Chrome DevTools Protocol
allows for tools to instrument,
inspect, debug and profile
chromium, chrome and any blink
based browsers. Chrome Devtools
uses this protocol to perform any
action on browser.
4
5
Demo
Listening to the protocol
SNIFFING CHROME DEVTOOLS PROTOCOL
Devtools via Chrome Extension
Devtools as Protocol Client.
6
DEBUGGING REMOTE INSTANCE OF CHROME
7
$ chrome --remote-debugging-port=9222 https://twpune.github.io/vodqa/
8
Demo
Attaching DevTools frontend to
the remotely running Chrome
instance for debugging
const WebSocket = require('ws');
var fs = require('fs');
ws = new
WebSocket("ws://localhost:9222/devtools/page/387D2CABAF785990F1694
0EEF89BF032");
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.googl
e.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();
});
PUPPETEER
Node library which provides a high-level API to control Chrome or Chromium
over the DevTools Protocol
1
0
PYRAMID OF PUPPETEER
1
1
Script
PUPPETEER
Installation:
■ Zero configuration
■ Bundles latest chromium
■ High level API’s for the common use cases
■ asyn/await latest JS features
Execution:
1
2
“A Puppeteer is a
person who
manipulates an
inanimate object
that might be
shaped like a
human, animal or
mythical creature
or another object
to create the
illusion that the
puppet is alive”
npm i puppeteer --save
node test_name.js
HOW TO LAUNCH CHROME IN HEADFUL MODE
1
3
const browser = await puppeteer.launch({
headless: false,
executablePath: '/usr/bin/chrome'
});
1
4
Test optimization using
puppeteer
DON’T HAVE TO WAIT FOR THE ENTIRE PAGE TO LOAD
1
5
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');
ABORT UNNECESSARY REQUESTS
1
6
// 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/');
1
7
Advanced puppeteer
examples
HANDLING HTTP BASIC AUTHENTICATION
1
8
{
"id": 2,
"method": "Network.setExtraHTTPHeaders",
"params": {
"headers": {
"Authorization": "Basic
YWRtaW46YWRtaW4="
}
}
}
Websocket JSON request
NETWORK EMULATION
1
9
{
"id": 7,
"method": "Network.emulateNetworkConditions",
"params": {
"offline": true,
"latency": 300,
"downloadThroughput": 250,
"uploadThroughput": 750
}
}
Websocket JSON request
MOCK GEO LOCATION
2
0
{
"id": 3,
"method": "Page.setGeolocationOverride",
"params": {
"latitude": 27.1752868,
"longitude": 78.040009,
"accuracy": 100
}
}
Websocket JSON request
MAKE YOUR BROWSER TALK
2
1
OTHER EXAMPLES OF PUPPETEER
■ Scrap link from website
■ Device emulation - Keyboard API
■ Capture performance data
■ Capture timeline trace
■ Testing Offline
■ Create pdf of the website
■ A/B testing
2
2
Can my existing tests suit in
selenium take advantage of
chrome Devtools??
2
3
SELENIUM, REMOTE DEBUGGING THE BROWSER
2
4
MULTI-CLIENT REMOTE DEBUGGING SUPPORT
2
5
ENABLING CHROME DRIVER LOGS
2
6
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_P
ROPERTY, System.getProperty("user.dir") +
"/target/chromedriver.log");
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_P
ROPERTY, System.getProperty("user.dir") +
"/driver/chromedriver.exe");
ChromeDriverService service = new ChromeDriverService.Builder()
.usingAnyFreePort()
.withVerbose(true)
.build();
service.start();
SELENIUM
AND
DEVTOOLS
■ Enable chrome driver logs by setting system
property “ CHROME_DRIVER_LOG_PROPERTY”
■ Launch a chrome browser using
ChromeDriverService.
■ Parse the chromedriver logs to get the port on which
remote debugger is running.
■ Use the debugger port to make websocket socket
connections.
2
7
{ "description": "",
"devtoolsFrontendUrl":
"/devtools/inspector.html?ws=localhost:12326/devtools/page/4f500019-edde-4c1
e-a464-699638eb5fce",
"id": "4f500019-edde-4c1e-a464-699638eb5fce",
"title": "data:,",
"type": "page",
"url": "data:,",
"webSocketDebuggerUrl":
"ws://localhost:12326/devtools/page/4f500019-edde-4c1e-a464-699638eb5fce"}
REMOTE DEBUG
RemoteDebug
Is an initiative to bring a common
remote debugging protocol to
today’s browser. The vision is to
enable a new generation of
DevTools and editors that are able
to communicate independently of
their vendors.
- Kenneth Auchenberg
2
8
Conclusion
Chrome Debugging Protocol has unlocked
possibility to automate web application
using devtool.
Puppeteer made our life easier by providing
high level API to write highly reliable tests and
perform non functional testing like network
throttling, device emulation, performance tests
and etc.
2
9
“Conclusion is the
place you get tired
of thinking.”
REFERENCE
https://github.com/transitive-bullshit/awesome-puppeteer
https://github.com/dhamaniasad/HeadlessBrowsers
https://developers.google.com/web/updates/2017/04/headless-chro
me
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-integratio
n
Try Puppeteer online : https://try-puppeteer.appspot.com/
Puppeteer documentation : https://pptr.dev/
3
0
THANK YOU
Shilpa G
shilpag.398ckm@gmail.com
LinkedIn - /gshilpa3
Github - /Shilpagopal

More Related Content

What's hot

Robotframework
RobotframeworkRobotframework
RobotframeworkElla Sun
 
Protractor for angularJS
Protractor for angularJSProtractor for angularJS
Protractor for angularJSKrishna Kumar
 
Qc dept open_sta overview
Qc dept open_sta overviewQc dept open_sta overview
Qc dept open_sta overviewqc-pyramid
 
Основы нагрузочного тестирования с инструментом Jmeter
Основы нагрузочного тестирования с инструментом JmeterОсновы нагрузочного тестирования с инструментом Jmeter
Основы нагрузочного тестирования с инструментом JmeterКомпьютерная школа Hillel
 
Introducing Ghost Inspector
Introducing Ghost InspectorIntroducing Ghost Inspector
Introducing Ghost InspectorNeil Mansilla
 
Rails automatic test driven development
Rails automatic test driven developmentRails automatic test driven development
Rails automatic test driven developmenttyler4long
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction SheetvodQA
 
Performance testing with VSTs on- and off-premises
Performance testing with VSTs on-  and off-premisesPerformance testing with VSTs on-  and off-premises
Performance testing with VSTs on- and off-premisesJeff Bramwell
 
Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteMediacurrent
 
Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016Steinn 'Stan' Jónsson
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot FrameworkFurkan Ertürk
 
Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Andrew Eisenberg
 
Automation testing with Drupal 8
Automation testing with Drupal 8Automation testing with Drupal 8
Automation testing with Drupal 8nagpalprachi
 
Webservice performance testing with SoapUI
Webservice performance testing with SoapUIWebservice performance testing with SoapUI
Webservice performance testing with SoapUIPhuoc Nguyen
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolSperasoft
 
Fabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyFabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyYaroslav Pernerovsky
 

What's hot (20)

Robotframework
RobotframeworkRobotframework
Robotframework
 
Protractor for angularJS
Protractor for angularJSProtractor for angularJS
Protractor for angularJS
 
Qc dept open_sta overview
Qc dept open_sta overviewQc dept open_sta overview
Qc dept open_sta overview
 
Ui Testing with Ghost Inspector
Ui Testing with Ghost InspectorUi Testing with Ghost Inspector
Ui Testing with Ghost Inspector
 
Основы нагрузочного тестирования с инструментом Jmeter
Основы нагрузочного тестирования с инструментом JmeterОсновы нагрузочного тестирования с инструментом Jmeter
Основы нагрузочного тестирования с инструментом Jmeter
 
Introducing Ghost Inspector
Introducing Ghost InspectorIntroducing Ghost Inspector
Introducing Ghost Inspector
 
Robot framework
Robot frameworkRobot framework
Robot framework
 
Rails automatic test driven development
Rails automatic test driven developmentRails automatic test driven development
Rails automatic test driven development
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction Sheet
 
Performance testing with VSTs on- and off-premises
Performance testing with VSTs on-  and off-premisesPerformance testing with VSTs on-  and off-premises
Performance testing with VSTs on- and off-premises
 
Protractor overview
Protractor overviewProtractor overview
Protractor overview
 
Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal Site
 
Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016Testing Web Services - QA or the Highway 2016
Testing Web Services - QA or the Highway 2016
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot Framework
 
Robot framework and selenium2 library
Robot framework and selenium2 libraryRobot framework and selenium2 library
Robot framework and selenium2 library
 
Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015Protractor Tutorial Quality in Agile 2015
Protractor Tutorial Quality in Agile 2015
 
Automation testing with Drupal 8
Automation testing with Drupal 8Automation testing with Drupal 8
Automation testing with Drupal 8
 
Webservice performance testing with SoapUI
Webservice performance testing with SoapUIWebservice performance testing with SoapUI
Webservice performance testing with SoapUI
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI Tool
 
Fabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyFabulous Tests on Spock and Groovy
Fabulous Tests on Spock and Groovy
 

Similar to vodQA Pune (2019) - Browser automation using dev tools

Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIubunturk
 
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)Kazuaki Matsuo
 
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...Building Blocks
 
Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIWilson Su
 
Headless browser: puppeteer and git client : GitKraken
Headless browser: puppeteer and git client : GitKrakenHeadless browser: puppeteer and git client : GitKraken
Headless browser: puppeteer and git client : GitKrakenSheikhMoonwaraAnjumM
 
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
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsNick Belhomme
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with AppiumLuke Maung
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsersSergey Shekyan
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdframya9288
 
How to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptx
How to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptxHow to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptx
How to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptxBOSC Tech Labs
 
Web dev tools review
Web dev tools reviewWeb dev tools review
Web dev tools reviewChanghyun Lee
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Google chrome presentation
Google chrome presentationGoogle chrome presentation
Google chrome presentationreza jalaluddin
 
Mobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructureMobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructureMichael Palotas
 

Similar to vodQA Pune (2019) - Browser automation using dev tools (20)

Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node API
 
Puppeteer
PuppeteerPuppeteer
Puppeteer
 
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)
 
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
Technical Tips: Visual Regression Testing and Environment Comparison with Bac...
 
Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node API
 
Headless browser: puppeteer and git client : GitKraken
Headless browser: puppeteer and git client : GitKrakenHeadless browser: puppeteer and git client : GitKraken
Headless browser: puppeteer and git client : GitKraken
 
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)
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance tests
 
VorlonJS
VorlonJSVorlonJS
VorlonJS
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdf
 
Intro to Puppeteer
Intro to PuppeteerIntro to Puppeteer
Intro to Puppeteer
 
How to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptx
How to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptxHow to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptx
How to Develop Progressive Web Apps in Flutter – Step by Step Guide.pptx
 
Web dev tools review
Web dev tools reviewWeb dev tools review
Web dev tools review
 
Vorlon.js
Vorlon.jsVorlon.js
Vorlon.js
 
[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design[refreshaustin] Adaptive Images in Responsive Web Design
[refreshaustin] Adaptive Images in Responsive Web Design
 
Google chrome presentation
Google chrome presentationGoogle chrome presentation
Google chrome presentation
 
Mobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructureMobile Test Automation using one API and one infrastructure
Mobile Test Automation using one API and one infrastructure
 

More from vodQA

Performance Testing
Performance TestingPerformance Testing
Performance TestingvodQA
 
Testing Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architectureTesting Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architecturevodQA
 
Testing face authentication on mobile
Testing face authentication on mobileTesting face authentication on mobile
Testing face authentication on mobilevodQA
 
Testing cna
Testing cnaTesting cna
Testing cnavodQA
 
Etl engine testing with scala
Etl engine testing with scalaEtl engine testing with scala
Etl engine testing with scalavodQA
 
EDA for QAs
EDA for QAsEDA for QAs
EDA for QAsvodQA
 
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 challengesvodQA
 
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 applicationsvodQA
 
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 automationvodQA
 
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 contractsvodQA
 
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 testingvodQA
 
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 deploymentsvodQA
 
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 codevodQA
 
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 pactvodQA
 
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
 
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
 
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 wayvodQA
 
vodQA(Pune) 2018 - Docker in Testing
vodQA(Pune) 2018 - Docker in TestingvodQA(Pune) 2018 - Docker in Testing
vodQA(Pune) 2018 - Docker in TestingvodQA
 
Mobile automation using appium.pptx
Mobile automation using appium.pptxMobile automation using appium.pptx
Mobile automation using appium.pptxvodQA
 
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 beginnersvodQA
 

More from vodQA (20)

Performance Testing
Performance TestingPerformance Testing
Performance Testing
 
Testing Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architectureTesting Strategy in Micro Frontend architecture
Testing Strategy in Micro Frontend architecture
 
Testing face authentication on mobile
Testing face authentication on mobileTesting face authentication on mobile
Testing face authentication on mobile
 
Testing cna
Testing cnaTesting cna
Testing cna
 
Etl engine testing with scala
Etl engine testing with scalaEtl engine testing with scala
Etl engine testing with scala
 
EDA for QAs
EDA for QAsEDA for QAs
EDA for QAs
 
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
 

Recently uploaded

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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 DiscoveryTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

vodQA Pune (2019) - Browser automation using dev tools

  • 1. BROWSER AUTOMATION USING DEVTOOLS VODQA Pune 2019 By : Shilpa G QA at ThoughtWorks LinkedIn - /gshilpa3 Github - /Shilpagopal
  • 2. WHY DEVTOOLS? Limitation of existing tools to automate all the browser supported features. ■ Handling HTTP basic authentications ■ Getting events from browser ■ Setting fake geo location ■ Updating User-agent ■ Interception web responses ■ Network Simulation ■ Screen casting chrome session Chrome Devtools unlocks the possibility to automate most of the browser supported features. 2 “We can’t solve our problems with the same thinking we used when we created them” - Albert Einstein
  • 4. Chrome DevTools Protocol allows for tools to instrument, inspect, debug and profile chromium, chrome and any blink based browsers. Chrome Devtools uses this protocol to perform any action on browser. 4
  • 6. SNIFFING CHROME DEVTOOLS PROTOCOL Devtools via Chrome Extension Devtools as Protocol Client. 6
  • 7. DEBUGGING REMOTE INSTANCE OF CHROME 7 $ chrome --remote-debugging-port=9222 https://twpune.github.io/vodqa/
  • 8. 8 Demo Attaching DevTools frontend to the remotely running Chrome instance for debugging
  • 9. const WebSocket = require('ws'); var fs = require('fs'); ws = new WebSocket("ws://localhost:9222/devtools/page/387D2CABAF785990F1694 0EEF89BF032"); 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.googl e.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(); });
  • 10. PUPPETEER Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol 1 0
  • 12. PUPPETEER Installation: ■ Zero configuration ■ Bundles latest chromium ■ High level API’s for the common use cases ■ asyn/await latest JS features Execution: 1 2 “A Puppeteer is a person who manipulates an inanimate object that might be shaped like a human, animal or mythical creature or another object to create the illusion that the puppet is alive” npm i puppeteer --save node test_name.js
  • 13. HOW TO LAUNCH CHROME IN HEADFUL MODE 1 3 const browser = await puppeteer.launch({ headless: false, executablePath: '/usr/bin/chrome' });
  • 15. DON’T HAVE TO WAIT FOR THE ENTIRE PAGE TO LOAD 1 5 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');
  • 16. ABORT UNNECESSARY REQUESTS 1 6 // 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/');
  • 18. HANDLING HTTP BASIC AUTHENTICATION 1 8 { "id": 2, "method": "Network.setExtraHTTPHeaders", "params": { "headers": { "Authorization": "Basic YWRtaW46YWRtaW4=" } } } Websocket JSON request
  • 19. NETWORK EMULATION 1 9 { "id": 7, "method": "Network.emulateNetworkConditions", "params": { "offline": true, "latency": 300, "downloadThroughput": 250, "uploadThroughput": 750 } } Websocket JSON request
  • 20. MOCK GEO LOCATION 2 0 { "id": 3, "method": "Page.setGeolocationOverride", "params": { "latitude": 27.1752868, "longitude": 78.040009, "accuracy": 100 } } Websocket JSON request
  • 21. MAKE YOUR BROWSER TALK 2 1
  • 22. OTHER EXAMPLES OF PUPPETEER ■ Scrap link from website ■ Device emulation - Keyboard API ■ Capture performance data ■ Capture timeline trace ■ Testing Offline ■ Create pdf of the website ■ A/B testing 2 2
  • 23. Can my existing tests suit in selenium take advantage of chrome Devtools?? 2 3
  • 24. SELENIUM, REMOTE DEBUGGING THE BROWSER 2 4
  • 26. ENABLING CHROME DRIVER LOGS 2 6 System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_P ROPERTY, System.getProperty("user.dir") + "/target/chromedriver.log"); System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_P ROPERTY, System.getProperty("user.dir") + "/driver/chromedriver.exe"); ChromeDriverService service = new ChromeDriverService.Builder() .usingAnyFreePort() .withVerbose(true) .build(); service.start();
  • 27. SELENIUM AND DEVTOOLS ■ Enable chrome driver logs by setting system property “ CHROME_DRIVER_LOG_PROPERTY” ■ Launch a chrome browser using ChromeDriverService. ■ Parse the chromedriver logs to get the port on which remote debugger is running. ■ Use the debugger port to make websocket socket connections. 2 7 { "description": "", "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:12326/devtools/page/4f500019-edde-4c1 e-a464-699638eb5fce", "id": "4f500019-edde-4c1e-a464-699638eb5fce", "title": "data:,", "type": "page", "url": "data:,", "webSocketDebuggerUrl": "ws://localhost:12326/devtools/page/4f500019-edde-4c1e-a464-699638eb5fce"}
  • 28. REMOTE DEBUG RemoteDebug Is an initiative to bring a common remote debugging protocol to today’s browser. The vision is to enable a new generation of DevTools and editors that are able to communicate independently of their vendors. - Kenneth Auchenberg 2 8
  • 29. Conclusion Chrome Debugging Protocol has unlocked possibility to automate web application using devtool. Puppeteer made our life easier by providing high level API to write highly reliable tests and perform non functional testing like network throttling, device emulation, performance tests and etc. 2 9 “Conclusion is the place you get tired of thinking.”
  • 31. THANK YOU Shilpa G shilpag.398ckm@gmail.com LinkedIn - /gshilpa3 Github - /Shilpagopal