0% found this document useful (0 votes)
62 views

(Document) Selenium 4: Intro To CDP

The document introduces the Chrome Debugging Protocol (CDP), which is a new Selenium 4 API feature. CDP allows automation of the developer tools in Chrome and Microsoft Edge. It works by the EdgeDriver and ChromeDriver classes extending the ChromiumDriver class, which itself extends RemoteWebDriver. The ChromiumDriver class contains methods like executeCdpCommand and getDevTools that allow controlling the developer tools programmatically.

Uploaded by

Vinaya Chennadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

(Document) Selenium 4: Intro To CDP

The document introduces the Chrome Debugging Protocol (CDP), which is a new Selenium 4 API feature. CDP allows automation of the developer tools in Chrome and Microsoft Edge. It works by the EdgeDriver and ChromeDriver classes extending the ChromiumDriver class, which itself extends RemoteWebDriver. The ChromiumDriver class contains methods like executeCdpCommand and getDevTools that allow controlling the developer tools programmatically.

Uploaded by

Vinaya Chennadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Selenium 4 Intro

To Chrome DevTools Protocol


Hello and Welcome, in this session, I will talk about CDP which is an acronym for Chrome Debugging
Protocol. It’s a new Selenium 4 API feature that’s designed for debuggers. All browsers built on the
Chromium platform has an option for Developer Tools. Therefore, another name for CDP can be called
Chrome DevTools Protocol.

If I go to Chrome then click this vertical ellipsis, navigate to More Tools, and at this point, we see
Developer Tools. DevTools is short for Developer Tools. Click and we see a few tabs. Elements is the
most popular tab for Automation but we also have Console, Sources, Network, Performance, Memory
Application, and Security. It’s the same panel if I right click a page and click Inspect.

Microsoft Edge also has these same tabs after accessing Developer Tools. We click this ellipsis, More
Tools and here’s Developer Tools.

Selenium 4 provides a way for us to take advantage of Chrome and Microsoft Edge’s debugging
protocol. Let’s look behind the scenes at the classes and methods. Starting with selenium-chromium-
driver, we see the ChromiumDriver class, open the Type Hierarchy. Notice, the ChromeDriver and

Page 1 of 5
EdgeDriver classes are both under the ChromiumDriver class. That’s because ChromiumDriver is the
parent. However, ChromiumDriver is a child to the parent RemoteWebDriver.

In a nutshell, EdgeDriver extends ChromiumDriver. ChromeDriver extends ChromiumDriver but


ChromiumDriver extends RemoteWebDriver.

Page 2 of 5
There’s a lot of methods in the ChromiumDriver class but 2 methods allow us to control Developer Tools
in Chrome and Microsoft Edge.

Page 3 of 5
Those 2 methods are executeCdpCommand and getDevTools. The executeCdpCommand allows us to
directly execute a Chrome DevTool Protocol command by passing in a parameter for that command.
getDevTools is a method that returns DevTools.

DevTools is a class that has methods to handle developer options. We see close, send, addListener.
Know what, let me go back to the Project Explorer and look at the methods for DevTools. Here are the
methods within DevTools: addListener, clearListener, close, createSession,
createSessionIfThereIsNotOne, getCdpSession, and send.

We see a lot of methods for DevTools because we can do a lot of things with CDP. I’m going to show you
how to view the Console Logs when it comes to CDP, Mock a GeoLocation, and Enable the Network
Speed. Thanks for watching and I’ll see you in the next session starting with View Console Logs. If you
are interested in more videos, feel free to subscribe to my YouTube channel and click the bell icon. Also,
follow me on Twitter, connect with me on LinkedIn and Facebook.

Contact

✔ YouTube https://www.youtube.com/c/RexJonesII/videos

Page 4 of 5
✔ Facebook https://facebook.com/JonesRexII

✔ Twitter https://twitter.com/RexJonesII

✔ GitHub https://github.com/RexJonesII/Free-Videos

✔ LinkedIn https://www.linkedin.com/in/rexjones34/

Page 5 of 5

You might also like