14

As we known WebDriver protocol is design for automation test purpose. But the major browsers also provide DevTool protocol. In some cases the DevTool protocol could achieve more powerful interactions and operations compare to WebDriver.

My question is why there are two different protocols and what's the main difference between these two protocols? Is there any selection experience available to share for a project development?

Thanks in advance!

Reference:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Erxin
  • 1,786
  • 4
  • 19
  • 33

2 Answers2

18

Main difference between WebDriver protocol and DevTools protocol is that WebDriver protocol needs a middle man like browser-driver (eg: chrome-driver) which is a server that sits between the automation script and browser enabling browser control, but in case of DevTools protocol the automation script can directly talk to browser running in debug mode making headless automation pretty straight forward.

And Chrome driver internally uses DevTools protocol to control browser, so if we are using WebDriver protocol it will in turn use Devtools protocol to control browser.

If cross-browser testing is something important for the new testing tool, DevTools protocol may not be suitable now, as there is no standard yet and it is mostly work in progress. Otherwise DevTools protocol will be a great choice as it gives more control like intercepting request header, simulating network etc and makes headless automation way easier.

par
  • 817
  • 8
  • 21
8

WebDriver

WebDriver supplies us a well-designed object-oriented API that can provide improved support for modern advanced web-applications created through dynamic web pages. In short, WebDriver is the remote control interface that enables us to introspect and control the user agents. It provides us a platform and language neutral wire protocol along with as a way for out-of-process programs to remotely instruct the behavior of Web Browsers.

WebDriver Specification

The WebDriver Specification was published by the Browser Testing and Tools Working Group as Editor's Draft. Editor's Draft does not imply endorsement by the W3C Membership and may be updated, replaced or obsoleted by other documents at any time.

DevTools Protocol

The Developer Tools Protocol is used by various Browsers, JavaScript Engines and debugging tools to:

  • Help web developers with a set of diagnostics tools which work well across a variety of targets.
  • To converge the need for target-specific devtools protocol adapters and simplify the experience for tool users and tool developers.
  • Provide a vendor-neutral platform to facilitate collaboration and mutual consensus building between different protocol implementations and interested clients.
  • Reduce the engineering investment necessary to build any further compatible protocol implementations as per user stories.

Some of the Browser Engines and Browsers those have a built-in debugging protocol are:

Some of the adapters that exposes a common protocol:

Here you can find the list of adapters in RemoteDebug - Protocol Adaptors


1. Note that DevTools Protocol for Firefox is Work In Progress

2. Note that DevTools Protocol for Edge is Work In Progress

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thank you for the explanation. one more question, to develop a web automation test framework, which protocol is better? – Erxin Jun 22 '18 at 06:46
  • @Erxin As I mentioned _WebDriver_ is a specification which you have to follow mandatory if working with _Selenium_, where as _DevTools Protocol_ have implementations through _Chrome DevTools Protocol_, _WebKit/webkit_, etc and you should always choose the one as per your _Test Specification_. The implementations are pretty much identical. – undetected Selenium Jun 23 '18 at 11:21
  • Update - The [edge dev tools protocol](https://learn.microsoft.com/en-us/microsoft-edge/devtools-protocol-chromium/) and [firefox remote protocol](https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html) are no longer "in development". – Sancarn Mar 18 '22 at 16:40