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…
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
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
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
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”}}