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
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/');
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
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.”