SlideShare a Scribd company logo
Chrome DevTools Protocol
via Selenium
Selenium Japan User Community Online Meetup
Kazuaki Matsuo
About Me
• Kazuaki Matsuo, KazuCocoa
• HeadSpin, Inc.
• Senior Software Engineer, Device Automation
• ex-Cookpad、ACCESS
• https://www.headspin.io/
• OSS
• Develop Appium project
Topics
• What is Chrome DevTools Protocol
• https://chromedevtools.github.io/devtools-protocol/
• Chrome DevTools Protocol via Selenium/Appium
Topics
• What is Chrome DevTools Protocol
• https://chromedevtools.github.io/devtools-protocol/
• Chrome DevTools Protocol via Selenium/Appium
What is Chrome DevTools Protocol
• Communicate with Google Chrome browser directly
• https://developers.google.com/web/tools/chrome-devtools/
• Demo…
Remote feature
chrome://inspect —remote-debugger-port=9222
で起動する
Demo
Requests to chrome browser on the WebSocket
=> {"id":1,"method":"Network.enable","params":{"maxPostDataSize":65536}}
=> {"id":2,"method":"Page.enable"}
=> {"id":3,"method":"Page.getResourceTree"}
=> {"id":4,"method":"Runtime.enable"}
=> {"id":5,"method":"Debugger.enable","params":{"maxScriptsCacheSize":10000000}}
=> {"id":6,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}}
=> {"id":7,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":32}}
=> {"id":8,"method":"Profiler.enable"}
=> {"id":9,"method":"Log.enable"}
=> {"id":10,"method":"Log.startViolationsReport","params":{"config":[{"name":"longTask","threshold":200},
{"name":"longLayout","threshold":30},{"name":"blockedEvent","threshold":100},{"name":"blockedParser","threshold":-1},
{"name":"handler","threshold":150},{"name":"recurringHandler","threshold":50},
{"name":"discouragedAPIUse","threshold":-1}]}}
=> {"id":11,"method":"DOM.enable"}
=> {"id":12,"method":"CSS.enable"}
=> {"id":13,"method":"Overlay.enable"}
….
Recap-Chrome Devtools Protocol
• Communicate with Google Chrome browser directly
• https://developers.google.com/web/tools/chrome-devtools/
• Demo…
What can do
• e.g. Measure performance on the browser
• Pupetter can do the below link via CDP feature
• https://github.com/addyosmani/puppeteer-webperf
• Cannot get native contexts. Then, external service like HeadSpin is a
good place :)
• Please check the CDP page…
• It allows users to download an arbitrary file, for example, so please take
care of security issues when you make the debugger port public
Topics
• What is Chrome DevTools Protocol
• https://chromedevtools.github.io/devtools-protocol/
• Chrome DevTools Protocol via Selenium/Appium
Chrome Devtools via Selenium
https://source.chromium.org/chromium/chromium/src/+/master:chrome/test/chromedriver/server/http_handler.cc;l=885?q=%2Fcdp%2Fexecute&ss=chromium&originalUrl=https:%2F
CDP via Selenium
ChromeDriver
port: 9515
Selenium clients
Command:
POST, /session/{session-id}/goog/cdp/execute
CDP via Selenium
ChromeDriver
port: 9515
Selenium clients
Command:
POST, /session/{session-id}/goog/cdp/execute
ChromeDriver
launches a browser
with
‘remote-debugger-address’
argument
Demo
Demo
> driver = Selenium::WebDriver.for :chrome, url: 'http://localhost:9515'
=> #<Selenium::WebDriver::Chrome::Driver:0x4d11f74261f6ab42 browser=:chrome>
> driver.get 'http://youtube.com'
=> nil
> driver.execute_cdp 'Browser.getVersion'
=> {"jsVersion"=>"8.1.307.32",
"product"=>"Chrome/81.0.4044.138",
"protocolVersion"=>"1.3",
"revision"=>"@8c6c7ba89cc9453625af54f11fd83179e23450fa",
"userAgent"=>
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/81.0.4044.138 Safari/537.36”}
> driver.execute_cdp ‘Page.navigate’, { url: ‘http://www.selenium.jp/’ }
Where is remote-debugger-address?
ChromeDriver
port: 9515
Selenium clients
Command:
POST, /session/{session-id}/goog/cdp/execute
ChromeDriver
launches a browser
with
‘remote-debugger-address’
argument
Dig in the session storage
to watch remote-debugger-address
> driver.session_storage
Dig in the session storage
to watch remote-debugger-address
> driver.session_storage
=> #<Selenium::WebDriver::HTML5::SessionStorage:0x00007fcf3802a418
@bridge=
#<Selenium::WebDriver::Remote::W3C::Bridge:0x00007fcf6010bd50
@browser=:chrome,
@capabilities=
#<Selenium::WebDriver::Remote::W3C::Capabilities:0x00007fcf6010bdc8
@capabilities=
{:proxy=>nil,
:browser_name=>"chrome",
……
{"chromedriverVersion"=>
"80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882})",
"userDataDir"=>
"/var/folders/34/2222sh8n27d6rcp7jqlkw8km0000gn/T/.com.google.Chrome.N74Q8x"},
"goog:chromeOptions"=>{"debuggerAddress"=>"localhost:53224"},
"networkConnectionEnabled"=>false,
"setWindowRect"=>true,
"strictFileInteractability"=>false,
"unhandledPromptBehavior"=>"dismiss and notify"}>,
@file_detector=nil,
Post the command via CURL
• Easy to add the command since you can send the command via
CURL
• curl -X POST http://localhost:9515/session/{session_id}/goog/cdp/
execute -d '{"cmd": "Browser.getVersion", "params": {}}’
• ‘goog’ is a vendor prefix
• MicrosoftEdge is ’ms’
• webdriverio communicates with CDP over Pupetter
Demo
Demo
curl -X POST http://localhost:9515/session/{session_id}/goog/cdp/execute -d '{"cmd": "Browser.getVersion", "params": {}}’
> {"value":{"jsVersion":"8.1.307.32","product":"Chrome/
81.0.4044.138","protocolVersion":"1.3","revision":"@8c6c7ba89cc9453625af54f11fd83179e23450fa","userAgent":"Mozilla/5.0 (Macintos
Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36”}}
CDP command over Appium
For Android Chrome
• Of course, the CDP command is available on Appium
• It requires Appium 1.18.0+
Demo
require 'appium_lib_core'
@core = Appium::Core.for url: 'http://localhost:4723/wd/hub', desired_capabilities: {
"deviceName": "Android",
"automationName": "UiAutomator2",
"autoAcceptsAlerts": "true",
"platformName": "Android",
"browserName": "chrome"
}
@driver = @core.start_driver
@driver.execute_cdp 'Browser.getVersion'
=> {"jsVersion"=>"6.9.427.23",
"product"=>"Chrome/69.0.3497.100",
"protocolVersion"=>"1.3",
"revision"=>"@8920e690dd011895672947112477d10d5c8afb09",
"userAgent"=>
"Mozilla/5.0 (Linux; Android 9; Android SDK built for x86_64 Build/PSR1.180720.093)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36"}
Appium server log
[HTTP] --> POST /wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/execute
[HTTP] {"cmd":"Browser.getVersion","params":{}}
[W3C (11d6751a)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/execute' to
command name 'executeCdp'
[debug] [WD Proxy] Proxying [POST /wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/
execute] to [POST http://127.0.0.1:8000/wd/hub/session/d54ca3ff98f09fa0a4c11ce14705b9e1/goog/cdp/
execute] with body: {"cmd":"Browser.getVersion","params":{}}
[debug] [WD Proxy] Got response with status 200:
{"sessionId":"d54ca3ff98f09fa0a4c11ce14705b9e1","status":0,"value":{"jsVersion":"6.9.427.23","product":"Chrome/
69.0.3497.100","protocolVersion":"1.3","revision":"@8920e690dd011895672947112477d10d5c8afb09","userAgent":"
Mozilla/5.0 (Linux; Android 9; Android SDK built for x86_64 Build/PSR1.180720.093) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36"}}
[WD Proxy] Replacing sessionId d54ca3ff98f09fa0a4c11ce14705b9e1 with 11d6751a-def1-4a1d-
a401-2d928bdf3065
[HTTP] <-- POST /wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/execute 200 411 ms - 388
[HTTP]
Topics
• What is Chrome DevTools Protocol
• Chrome DevTools Protocol via Selenium/Appium
One more thing: playwright
• Launches Chrome as pipe mode
• https://github.com/microsoft/playwright/blob/master/src/server/
chromium.ts#L177
• https://github.com/microsoft/playwright/tree/master/
browser_patches
Have a good automation
Twitter: @Kazu_cocoa

More Related Content

PDF
Appium basics
PDF
Appium Architecture | How Appium Works | Edureka
PPTX
Mobile Automation with Appium
PPTX
Appium an introduction
PDF
Getting started with appium
PDF
Angular data binding
PPTX
Appium Presentation
PPTX
Progressive Web Apps and React
Appium basics
Appium Architecture | How Appium Works | Edureka
Mobile Automation with Appium
Appium an introduction
Getting started with appium
Angular data binding
Appium Presentation
Progressive Web Apps and React

What's hot (20)

PDF
서버리스 IoT 백엔드 개발 및 구현 사례 : 윤석찬 (AWS 테크에반젤리스트)
PPTX
Appium overview
PPTX
Appium ppt
PPT
PDF
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...
PPT
PDF
AWS Fargate와 Amazon ECS를 사용한 CI/CD 베스트 프랙티스 - 유재석, AWS 솔루션즈 아키텍트 :: AWS Build...
PDF
AWS를 위한 도커, 컨테이너 (이미지) 환경 보안 방안 - 양희선 부장, TrendMicro :: AWS Summit Seoul 2019
PPT
RESTful API In Node Js using Express
PDF
AWS Summit Seoul 2023 | SK쉴더스: AWS Native Security 서비스를 활용한 경계보안
PPTX
Build progressive web apps with Angular
PPTX
Automation With Appium
PDF
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
PPTX
Intro to Azure Api Management - With Cats
PPTX
Automation testing on ios platform using appium
PDF
REST APIs with Spring
PPTX
Android Multimedia Player Project Presentation
PDF
Instagram Affiliate Marketing Secrets: A Step-by-Step Guide
PPTX
API Testing with Frisby and Mocha
PPTX
MicroServices on Azure
서버리스 IoT 백엔드 개발 및 구현 사례 : 윤석찬 (AWS 테크에반젤리스트)
Appium overview
Appium ppt
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...
AWS Fargate와 Amazon ECS를 사용한 CI/CD 베스트 프랙티스 - 유재석, AWS 솔루션즈 아키텍트 :: AWS Build...
AWS를 위한 도커, 컨테이너 (이미지) 환경 보안 방안 - 양희선 부장, TrendMicro :: AWS Summit Seoul 2019
RESTful API In Node Js using Express
AWS Summit Seoul 2023 | SK쉴더스: AWS Native Security 서비스를 활용한 경계보안
Build progressive web apps with Angular
Automation With Appium
도커 무작정 따라하기: 도커가 처음인 사람도 60분이면 웹 서버를 올릴 수 있습니다!
Intro to Azure Api Management - With Cats
Automation testing on ios platform using appium
REST APIs with Spring
Android Multimedia Player Project Presentation
Instagram Affiliate Marketing Secrets: A Step-by-Step Guide
API Testing with Frisby and Mocha
MicroServices on Azure
Ad

Similar to Chrome Devtools Protocol via Selenium/Appium (English) (20)

PDF
Chrome Devtools Protocol via Selenium/Appium (Japanese)
PDF
vodQA Pune (2019) - Browser automation using dev tools
PPTX
TAQELAH: Adding the Chrome Dev tools flavour to your Selenium tests
PPTX
Drive chrome(headless) with puppeteer
PDF
A Detailed Guide to Chrome Remote Debugging.pdf
PDF
Chrome Developer Tools with Selenoid
KEY
Getting started with Selenium 2
PDF
Selenium Full Material( apprendre Selenium).pdf
PDF
Browser-level testing
PPTX
A Deep Dive into the W3C WebDriver Specification
PPTX
Inspect The Uninspected
ODP
20091211 google chrome_developer_tools
PPTX
Selenium 101 Webinar
PPTX
Cross platform browser automation tests sdp
DOC
Selenium Automation Using Ruby
PDF
Selenium python
PDF
Selenium for Tester.pdf
PPTX
Get Started With Selenium 3 and Selenium 3 Grid
PDF
Introduction to Selenium and Ruby
PPTX
How to work with Selenium Grid and Cloud Solutions
Chrome Devtools Protocol via Selenium/Appium (Japanese)
vodQA Pune (2019) - Browser automation using dev tools
TAQELAH: Adding the Chrome Dev tools flavour to your Selenium tests
Drive chrome(headless) with puppeteer
A Detailed Guide to Chrome Remote Debugging.pdf
Chrome Developer Tools with Selenoid
Getting started with Selenium 2
Selenium Full Material( apprendre Selenium).pdf
Browser-level testing
A Deep Dive into the W3C WebDriver Specification
Inspect The Uninspected
20091211 google chrome_developer_tools
Selenium 101 Webinar
Cross platform browser automation tests sdp
Selenium Automation Using Ruby
Selenium python
Selenium for Tester.pdf
Get Started With Selenium 3 and Selenium 3 Grid
Introduction to Selenium and Ruby
How to work with Selenium Grid and Cloud Solutions
Ad

More from Kazuaki Matsuo (20)

PDF
2022-jasst-tohoku.pdf
PDF
Add new commands in appium 2.0
PDF
Manage appium dependencies with -appium-home in appium 2.0
PDF
20210616-career-example-at-icare
PDF
Xcode 11におけるXCUITestの挙動
PDF
20191130 system-automation-conference
PDF
Uncovering breaking changes behind UI on mobile applications
PDF
Start contributing to OSS projects on your way
PDF
Go ahead outside Japan
PDF
CookpadTechConf2018-(Mobile)TestAutomation
PDF
20171215 andoird-test-night
PDF
20170726 ios test_night_no
PDF
20170701 lets-step-into-the-oss-community
PDF
20170613 tech easy
PDF
20170529 clem kazuaki_matsuo
PDF
20150423 m3
PDF
20170302 tryswift tasting_tests
PDF
20161126 to ruby
PDF
20160914 te engineer
PDF
20160913 cookpad ios_jp
2022-jasst-tohoku.pdf
Add new commands in appium 2.0
Manage appium dependencies with -appium-home in appium 2.0
20210616-career-example-at-icare
Xcode 11におけるXCUITestの挙動
20191130 system-automation-conference
Uncovering breaking changes behind UI on mobile applications
Start contributing to OSS projects on your way
Go ahead outside Japan
CookpadTechConf2018-(Mobile)TestAutomation
20171215 andoird-test-night
20170726 ios test_night_no
20170701 lets-step-into-the-oss-community
20170613 tech easy
20170529 clem kazuaki_matsuo
20150423 m3
20170302 tryswift tasting_tests
20161126 to ruby
20160914 te engineer
20160913 cookpad ios_jp

Recently uploaded (20)

PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Essential Infomation Tech presentation.pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
System and Network Administraation Chapter 3
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Nekopoi APK 2025 free lastest update
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
medical staffing services at VALiNTRY
PDF
Digital Strategies for Manufacturing Companies
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Transform Your Business with a Software ERP System
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
How to Choose the Right IT Partner for Your Business in Malaysia
Essential Infomation Tech presentation.pptx
ai tools demonstartion for schools and inter college
System and Network Administraation Chapter 3
VVF-Customer-Presentation2025-Ver1.9.pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Softaken Excel to vCard Converter Software.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How Creative Agencies Leverage Project Management Software.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Nekopoi APK 2025 free lastest update
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
medical staffing services at VALiNTRY
Digital Strategies for Manufacturing Companies
CHAPTER 2 - PM Management and IT Context
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PTS Company Brochure 2025 (1).pdf.......
Transform Your Business with a Software ERP System
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises

Chrome Devtools Protocol via Selenium/Appium (English)

  • 1. Chrome DevTools Protocol via Selenium Selenium Japan User Community Online Meetup Kazuaki Matsuo
  • 2. About Me • Kazuaki Matsuo, KazuCocoa • HeadSpin, Inc. • Senior Software Engineer, Device Automation • ex-Cookpad、ACCESS • https://www.headspin.io/ • OSS • Develop Appium project
  • 3. Topics • What is Chrome DevTools Protocol • https://chromedevtools.github.io/devtools-protocol/ • Chrome DevTools Protocol via Selenium/Appium
  • 4. Topics • What is Chrome DevTools Protocol • https://chromedevtools.github.io/devtools-protocol/ • Chrome DevTools Protocol via Selenium/Appium
  • 5. What is Chrome DevTools Protocol • Communicate with Google Chrome browser directly • https://developers.google.com/web/tools/chrome-devtools/ • Demo…
  • 8. Requests to chrome browser on the WebSocket => {"id":1,"method":"Network.enable","params":{"maxPostDataSize":65536}} => {"id":2,"method":"Page.enable"} => {"id":3,"method":"Page.getResourceTree"} => {"id":4,"method":"Runtime.enable"} => {"id":5,"method":"Debugger.enable","params":{"maxScriptsCacheSize":10000000}} => {"id":6,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}} => {"id":7,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":32}} => {"id":8,"method":"Profiler.enable"} => {"id":9,"method":"Log.enable"} => {"id":10,"method":"Log.startViolationsReport","params":{"config":[{"name":"longTask","threshold":200}, {"name":"longLayout","threshold":30},{"name":"blockedEvent","threshold":100},{"name":"blockedParser","threshold":-1}, {"name":"handler","threshold":150},{"name":"recurringHandler","threshold":50}, {"name":"discouragedAPIUse","threshold":-1}]}} => {"id":11,"method":"DOM.enable"} => {"id":12,"method":"CSS.enable"} => {"id":13,"method":"Overlay.enable"} ….
  • 9. Recap-Chrome Devtools Protocol • Communicate with Google Chrome browser directly • https://developers.google.com/web/tools/chrome-devtools/ • Demo…
  • 10. What can do • e.g. Measure performance on the browser • Pupetter can do the below link via CDP feature • https://github.com/addyosmani/puppeteer-webperf • Cannot get native contexts. Then, external service like HeadSpin is a good place :) • Please check the CDP page… • It allows users to download an arbitrary file, for example, so please take care of security issues when you make the debugger port public
  • 11. Topics • What is Chrome DevTools Protocol • https://chromedevtools.github.io/devtools-protocol/ • Chrome DevTools Protocol via Selenium/Appium
  • 12. Chrome Devtools via Selenium https://source.chromium.org/chromium/chromium/src/+/master:chrome/test/chromedriver/server/http_handler.cc;l=885?q=%2Fcdp%2Fexecute&ss=chromium&originalUrl=https:%2F
  • 13. CDP via Selenium ChromeDriver port: 9515 Selenium clients Command: POST, /session/{session-id}/goog/cdp/execute
  • 14. CDP via Selenium ChromeDriver port: 9515 Selenium clients Command: POST, /session/{session-id}/goog/cdp/execute ChromeDriver launches a browser with ‘remote-debugger-address’ argument
  • 15. Demo
  • 16. Demo > driver = Selenium::WebDriver.for :chrome, url: 'http://localhost:9515' => #<Selenium::WebDriver::Chrome::Driver:0x4d11f74261f6ab42 browser=:chrome> > driver.get 'http://youtube.com' => nil > driver.execute_cdp 'Browser.getVersion' => {"jsVersion"=>"8.1.307.32", "product"=>"Chrome/81.0.4044.138", "protocolVersion"=>"1.3", "revision"=>"@8c6c7ba89cc9453625af54f11fd83179e23450fa", "userAgent"=> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36”} > driver.execute_cdp ‘Page.navigate’, { url: ‘http://www.selenium.jp/’ }
  • 17. Where is remote-debugger-address? ChromeDriver port: 9515 Selenium clients Command: POST, /session/{session-id}/goog/cdp/execute ChromeDriver launches a browser with ‘remote-debugger-address’ argument
  • 18. Dig in the session storage to watch remote-debugger-address > driver.session_storage
  • 19. Dig in the session storage to watch remote-debugger-address > driver.session_storage => #<Selenium::WebDriver::HTML5::SessionStorage:0x00007fcf3802a418 @bridge= #<Selenium::WebDriver::Remote::W3C::Bridge:0x00007fcf6010bd50 @browser=:chrome, @capabilities= #<Selenium::WebDriver::Remote::W3C::Capabilities:0x00007fcf6010bdc8 @capabilities= {:proxy=>nil, :browser_name=>"chrome", …… {"chromedriverVersion"=> "80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882})", "userDataDir"=> "/var/folders/34/2222sh8n27d6rcp7jqlkw8km0000gn/T/.com.google.Chrome.N74Q8x"}, "goog:chromeOptions"=>{"debuggerAddress"=>"localhost:53224"}, "networkConnectionEnabled"=>false, "setWindowRect"=>true, "strictFileInteractability"=>false, "unhandledPromptBehavior"=>"dismiss and notify"}>, @file_detector=nil,
  • 20. Post the command via CURL • Easy to add the command since you can send the command via CURL • curl -X POST http://localhost:9515/session/{session_id}/goog/cdp/ execute -d '{"cmd": "Browser.getVersion", "params": {}}’ • ‘goog’ is a vendor prefix • MicrosoftEdge is ’ms’ • webdriverio communicates with CDP over Pupetter
  • 21. Demo
  • 22. Demo curl -X POST http://localhost:9515/session/{session_id}/goog/cdp/execute -d '{"cmd": "Browser.getVersion", "params": {}}’ > {"value":{"jsVersion":"8.1.307.32","product":"Chrome/ 81.0.4044.138","protocolVersion":"1.3","revision":"@8c6c7ba89cc9453625af54f11fd83179e23450fa","userAgent":"Mozilla/5.0 (Macintos Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36”}}
  • 24. For Android Chrome • Of course, the CDP command is available on Appium • It requires Appium 1.18.0+
  • 25. Demo require 'appium_lib_core' @core = Appium::Core.for url: 'http://localhost:4723/wd/hub', desired_capabilities: { "deviceName": "Android", "automationName": "UiAutomator2", "autoAcceptsAlerts": "true", "platformName": "Android", "browserName": "chrome" } @driver = @core.start_driver @driver.execute_cdp 'Browser.getVersion' => {"jsVersion"=>"6.9.427.23", "product"=>"Chrome/69.0.3497.100", "protocolVersion"=>"1.3", "revision"=>"@8920e690dd011895672947112477d10d5c8afb09", "userAgent"=> "Mozilla/5.0 (Linux; Android 9; Android SDK built for x86_64 Build/PSR1.180720.093) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36"}
  • 26. Appium server log [HTTP] --> POST /wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/execute [HTTP] {"cmd":"Browser.getVersion","params":{}} [W3C (11d6751a)] Driver proxy active, passing request on via HTTP proxy [debug] [WD Proxy] Matched '/wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/execute' to command name 'executeCdp' [debug] [WD Proxy] Proxying [POST /wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/ execute] to [POST http://127.0.0.1:8000/wd/hub/session/d54ca3ff98f09fa0a4c11ce14705b9e1/goog/cdp/ execute] with body: {"cmd":"Browser.getVersion","params":{}} [debug] [WD Proxy] Got response with status 200: {"sessionId":"d54ca3ff98f09fa0a4c11ce14705b9e1","status":0,"value":{"jsVersion":"6.9.427.23","product":"Chrome/ 69.0.3497.100","protocolVersion":"1.3","revision":"@8920e690dd011895672947112477d10d5c8afb09","userAgent":" Mozilla/5.0 (Linux; Android 9; Android SDK built for x86_64 Build/PSR1.180720.093) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36"}} [WD Proxy] Replacing sessionId d54ca3ff98f09fa0a4c11ce14705b9e1 with 11d6751a-def1-4a1d- a401-2d928bdf3065 [HTTP] <-- POST /wd/hub/session/11d6751a-def1-4a1d-a401-2d928bdf3065/goog/cdp/execute 200 411 ms - 388 [HTTP]
  • 27. Topics • What is Chrome DevTools Protocol • Chrome DevTools Protocol via Selenium/Appium
  • 28. One more thing: playwright • Launches Chrome as pipe mode • https://github.com/microsoft/playwright/blob/master/src/server/ chromium.ts#L177 • https://github.com/microsoft/playwright/tree/master/ browser_patches
  • 29. Have a good automation Twitter: @Kazu_cocoa