How does chrome driver interact with Chrome browser?
Asked Answered
A

2

9

It says

ChromeDriver is a standalone server that implements the W3C WebDriver standard

It looks like W3C WebDriver standard only defines the interface between the automation program and Chromedriver. Chromedriver act as a HTTP server to get the command from automation program.

But how does ChromeDriver communicate with Chrome?

Still through HTTP protocol?

If yes, where could we get the documentation about the details? And what component inside of Chrome is in charge of handling the command from Chromedriver? Is it built in chrome or just an extension of Chrome?

Arlina answered 25/1, 2020 at 13:26 Comment(0)
A
5

To make it easy to find, I move the anwser here from comments.

Chrome driver controls Chrome browser through Chrome DevTools Protocol which is based on websocket. This article gives more details

Arlina answered 14/9, 2020 at 7:2 Comment(0)
P
6

At the core of Selenium is WebDriver, which is the remote control interface that enables introspection and control of user agents. WebDriver provides a platform and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers, hence instruction sets that can be run interchangeably in many browsers.


Selenium WebDriver refers to both the language bindings and the implementations of the individual browser controlling code and commonly referred as WebDriver. WebDriver is an API and protocol that defines a language-neutral interface for controlling the behaviour of web browsers. Each browser is backed by a specific WebDriver implementation, called a driver. The driver is the component responsible for delegating down to the browser, and handles communication to and from Selenium and the browser.


The Parts and Pieces

At its minimum requirement, WebDriver talks to a browser through a driver and the communication is two way:

  • WebDriver passes commands to the browser through the driver
  • Receives information back via the same route.

ChromeDriver

ChromeDriver is a standalone server that implements the W3C WebDriver standard. ChromeDriver is available for Chrome on Android and Chrome on Desktop (Mac, Linux, Windows and ChromeOS). The driver runs on the same system as the browser. This may, or may not be, the same system where the tests themselves are executing and is the example of direct communication.

basic_comms.png


Remote WebDriver

However, Communication to the browser may also be remote communication through Selenium Server or RemoteWebDriver. RemoteWebDriver runs on the same system as the driver and the browser.

basic_comms_driver_webdriver.png


Selenium Grid

Remote communication can also take place using Selenium Server or Selenium Grid, both of which in turn talk to the driver on the host system.

remote_comms_server.png


Communication through commands

The WebDriver protocol is organised into commands. Each HTTP request with a method and template defined in the specification represents a single command and hence each command produces a single HTTP response. In response to a command, the remote end will run a series of actions known as remote end steps. These provide the sequences of actions that a remote end takes when it receives a particular command.


Command Processing

The remote end is an HTTP server reading requests from the client and writing responses typically over a TCP socket. In the specification the communication is modeled as the data transmission between a particular local end and remote end with a connection to which the remote end may write bytes and read bytes. The exact details of how this connection works and how it is established is a bigger topic and out of scope for this question. After a connection has been established, the remote end must read bytes from the connection until a complete HTTP request can be constructed from the data. If it is not possible to construct a complete HTTP request, the remote end must either close the connection, return an HTTP response with status code 500, or return an error with error code unknown error.

Pilsudski answered 27/1, 2020 at 8:56 Comment(4)
@Arlina Checkout the updated answer and let me know if you have any questions.Pilsudski
thank you. But it seems it all about the interface between WebDriver and Driver(like ChromeDriver), not the interface between Driver (like ChromeDriver) and Browser (like Chrome) Why I'm curious about that? MicroSoft bring us Chromium based Edge Browser, we need to automate it with Selenium. As I known, Chromium has built-in web automation support (that's true because we could automate Electron App with Chromedriver). I want to know why bother MS provides Edge driver if existing ChromeDriver already could drive Chromium based Browser?Arlina
@Arlina I am sure you haven't read the complete answer. However your question involving Chromedriver act as a HTTP server, ChromeDriver communicate with Chrome and HTTP protocol is overly broad as per stackoverflow standards and I shouldn't have answered in the first place. Now as you have added more questions with respect to interface between Driver (like ChromeDriver) and Browser (like Chrome), Chromium based Edge Browser and Electron App, and an answer would be too big as per the space provided by SO.Pilsudski
I don't think I asked too broad question. And again I don't think this post anwsered my question. Because I finally found the true anwser. Chrome driver controls chrome through Chrome DevTools Protocol which based on websocket. This article gives more detailsArlina
A
5

To make it easy to find, I move the anwser here from comments.

Chrome driver controls Chrome browser through Chrome DevTools Protocol which is based on websocket. This article gives more details

Arlina answered 14/9, 2020 at 7:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.