Two popular facilities used by web automated testing framework are WebDriver
and DevTools
. Before going in detail let us take a look some of the entities we will be talking.
- WebDriver
- WebDriver protocol
- DevTools
- DevTools Protocol
- Chrome DevTools Protocol
WebDriver
is a browser specific module (kind of a remote agent) that we (or testing libraries such as Selenium etc) can interact with it by using WebDriver protocol
(it is a language-neutral wire protocol). The instructions we given to WebDriver
will be delivered to it's browser by using its own proprietary communication mechanism. The WebDriver protocol
consist of set of commands that abstract away common interactions with an application such as navigating
, clicking
, or reading the state of an element
etc. Since it is a web standard, it is well supported across all major browser vendors. The WebDriver protocol
is organized into commands; each HTTP request with a method and template defined in this specification represents a single command, and therefore each command produces a single HTTP response.
The DevTools
is proprietary browser native interface that is being used to debug the browser from a remote application. The Chrome DevTools
is from Chromium
and the protocol used in this case is Chrome DevTools Protocol
. Nowadays more and more browsers are adopting the Chrome DevTools Protocol
to interact with their browser DevTools. The DevTools approach offers more automation capabilities to the automation tools than using WebDriver. We (or testing framework) could use this facility to interact directly (without any proxy or agent) with the web browser and Chrome DevTools is using WebSockets
for this channel of communication. Then it is a bidirectional persistent connection between our testing framework module and the web browser.
Let us take a look on output snippet produced by the following Selenium node.js source code. We could see that it is using ws://127.0.0.1:51315
, a WebSockets port 51315
on local host (by DevTools).
DevTools listening on
ws://127.0.0.1:51315/devtools/browser/1c6fd882-e20d-44e9-9a86-bebcf93a514e
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('https://www.amazon.com/');
driver.quit();