DevTools and Headless Chrome - The Automation Power-Couple

A presentation at Øredev Developer Conference in November 2018 in Malmö, Sweden by Yonatan Mevorach

Slide 1

Slide 1

DEVTOOLS & HEADLESS CHROME: THE AUTOMATION POWER-COUPLE

Slide 2

Slide 2

Yonatan Mevorach @cowchimp

Slide 3

Slide 3

Slide 4

Slide 4

Slide 5

Slide 5

Slide 6

Slide 6

”I can’t automate this” -- no one ever (after watching this talk)

Slide 7

Slide 7

Web Automation youtu.be/fsF7enQY8uI

Slide 8

Slide 8

Headless Browsers cbnd flic.kr/p/qnSPdN

Slide 9

Slide 9

Chrome

Slide 10

Slide 10

headless Chrome

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

[ ] { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": { "time": // ... "09:00", "10:30", "10:30", "10:30", "10:30", "10:30", "10:30", "10:30", "11:30", "11:30", "11:30", "11:30", "11:30", "11:30", "11:30", "12:50", "12:50", "12:50", "12:50", "12:50", "12:50", "12:50", "13:50", "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "title": "Hacking the World with Digital Biology" }, "Building Mixed Reality Apps" }, "12-Factor, Cloud Native Enterprise Java Applications" }, "Building Evolutionary Architectures" }, "What's New in CSS?" }, "Building Performant Backends with Elixir" }, "ASP.NET Core in Production: Lessons Learned" }, "Stop Building Useless Software" }, "GDPR Compliance for Your Datastore" }, "Having Your Cake and Eating It Too — GraphQL in Reason" }, "The New Paradigm For Leading Teams in the Digital Age" }, "Dissecting the stdlib" }, "Reality is Becoming Virtual" }, "Functional Patterns for the Object Oriented" }, "Designing Distributed Systems with TLA+" }, "TDD on Android: Why and how?" }, "Practice Safe Networking" }, "Crafting Faster in the Dark" }, "Behind the Scenes at Gapminder: A Story about Data and Visualizations" }, "The Future of QA in the Age of AI" }, "Blazor, a New .NET Single Page Application Framework" }, "How to Be a High Performing Distributed Agile Team" }, "Java with a Clojure Mindset" },

Slide 14

Slide 14

Slide 15

Slide 15

Slide 16

Slide 16

Slide 17

Slide 17

Slide 18

Slide 18

Slide 19

Slide 19

Slide 20

Slide 20

Slide 21

Slide 21

Slide 22

Slide 22

Slide 23

Slide 23

Slide 24

Slide 24

Slide 25

Slide 25

headless Chrome

Slide 26

Slide 26

headless Firefox

Slide 27

Slide 27

Chrome DevTools

Slide 28

Slide 28

Slide 29

Slide 29

Slide 30

Slide 30

Slide 31

Slide 31

protocol Chrome DevTools

Slide 32

Slide 32

DevTools Embedding Frontendapp WebSockets ChromeAPI Headless Adapted from content by © Sami Kyöstilä, Google goo.gl/yQi9kZ

Slide 33

Slide 33

{ id: 1, method: "Runtime.evaluate", params: { expression: "1 + 1" } } DevTools Embedding Frontendapp ChromeAPI Headless Adapted from content by © Sami Kyöstilä, Google goo.gl/yQi9kZ

Slide 34

Slide 34

{ id: 1, method: "Runtime.evaluate", params: { expression: "1 + 1" } } DevTools Embedding Frontendapp ChromeAPI Headless { id: 1, result: { result: { type: "number", value: 2, description: "2" }, wasThrown: false } } Adapted from content by © Sami Kyöstilä, Google goo.gl/yQi9kZ

Slide 35

Slide 35

Slide 36

Slide 36

Accessibility Cache storage Animation Console CSS Device orientation DOM Emulation Heap profiler Inspector Page Application cache IO Profiler Service worker Database DOM debugger Debugger DOM storage IndexedDB Layer tree Rendering Input Memory Runtime Tracing Network Security Worker Adapted from content by © Sami Kyöstilä, Google goo.gl/yQi9kZ

Slide 37

Slide 37

DevTools Embedding client app DevTools Headlesstarget API Adapted from content by © Sami Kyöstilä, Google goo.gl/yQi9kZ

Slide 38

Slide 38

node --inspect index.js

Slide 39

Slide 39

Slide 40

Slide 40

Slide 41

Slide 41

Slide 42

Slide 42

Slide 43

Slide 43

headless protocol

Slide 44

Slide 44

chrome --headless --remote-debugging-port=9222 http://oredev.org

Slide 45

Slide 45

chrome --headless --remote-debugging-port=9222 http://oredev.org

Slide 46

Slide 46

chrome --headless --remote-debugging-port=9222 http://oredev.org

Slide 47

Slide 47

chrome --headless --remote-debugging-port=9222 http://oredev.org

Slide 48

Slide 48

chrome --headless --remote-debugging-port=9222 http://oredev.org

Slide 49

Slide 49

Slide 50

Slide 50

DevTools Protocol Selenium Puppeteer

Slide 51

Slide 51

Slide 52

Slide 52

Slide 53

Slide 53

Slide 54

Slide 54

pixabay.com/photo-175605

Slide 55

Slide 55

pixabay.com/photo-175605

Slide 56

Slide 56

Slide 57

Slide 57

Slide 58

Slide 58

Slide 59

Slide 59

Slide 60

Slide 60

Slide 61

Slide 61

Slide 62

Slide 62

Slide 63

Slide 63

Slide 64

Slide 64

Slide 65

Slide 65

Recap! goo.gl/j41BaC

Slide 66

Slide 66

tinyurl.com/ headless-talk @cowchimp blog.cowchimp.com