Headless browser - WebDriver / ChromeDriver (automated testing - W3C WebDriver API )

Browser

About

A WebDriver is a application:

  • that control / drive real browsers.
  • via function that are available via the the WebDriver API

Each browser is backed by a specific WebDriver implementation, called a driver.

You interact with a device, with a database via a driver. With a webdriver, you interact with a browser

It was at first developped by selenium.

They are now standardized via the W3c WebDriver API 1) (that has replaced the WebDriver's wire protocol 2) ) that defines a language-neutral interface and protocol for controlling web browsers.

They are mostly used to automated testing of web apps.

Note that the concept of driver has been extended and you can also drive for instance:

Model

Because it is an out-of-process library that instructs the browser what to do, and because the web platform has an intrinsically asynchronous nature, WebDriver does not track the active, real-time state of the DOM.

The default page load strategy used in WebDriver listens for the document.readyState to change to complete before returning from the call to navigate.

API / DSL

Code:

Library

Web Driver Library (Selenium)

selenium was the first to introduce webdriver

Selenium supports many language (Java, Python, Javascript, …). The php binding is known as php-webdriver

WebDriver Wrapper Library

This library are higher level API built on top of WebDriver

  • WebDriverIO 3). This is a browser and mobile automation test framework for Node.js that is included in webdriverio-testing-library
  • Cypress - The test are in a browser window that stay open - a test runner used for End-to-End (E2E) and Integration Testing.
  • Nightwatch - Npm Selenium binding library - End-to-end testing
  • https://playwright.dev/ - a testing framework that lets you automate Chromium, Firefox, and WebKit with a single API. You can use it to write End-to-End (E2E) and Integration

Cloud

Remote Web Driver

You can use WebDriver remotely (ie by connecting to it remotely as a service) the same way you would use it locally. The primary difference is that a remote WebDriver needs to be configured so that it can run your tests on a separate machine.

Run Selenium is remotely via a docker image for instance. (See browserless

Steps:

java -jar selenium-server-standalone-{VERSION}.jar
const { Builder, Capabilities } = require("selenium-webdriver");
var capabilities = Capabilities.firefox();
(async function helloSelenium() {
    let driver = new Builder()
        .usingServer("http://localhost:8080")   
        .withCapabilities(capabilities)
        .build();
    try {
        await driver.get('http://www.google.com');
    } finally {
        await driver.quit();
    }
})();  

More https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Your_own_automation_environment

List

The drivers are all server executables:

ChromeDriver

ChromeDriver 5) is a standalone server which implements WebDriver's wire protocol for Chromium. It is being developed by members of the Chromium and WebDriver teams.

It's a wrapper around the Chrome Devtool protocol

The downloaded version should match the version of chrome. 6)

chromedriver.exe --port=4444
Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Geckodriver

Geckodriver is the driver for firefox 7)

msedgedriver

Edge - https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Update

You can update the webdriver via the following manager:

  • OS Package Manager: Chromedriver may be available in some Linux distributions (for example as chromium-chromedriver package in Ubuntu)
  • Driver Manager 8): A piece of software created uniquely for this purpose

Specification

Documentation / Reference





Discover More
Browser
Browser Automation - Selenium

Selenium is a suite of tools to automate web browsers across many platforms. At the core of Selenium is WebDriver, it's a code interface and implementation to manipulate...
Browser
Chrome DevTool protocol (CDP)

The is a API that permits to call browsers implementing the CDP api (chrome of course but also any other browser implementation ) via json RPC. The protocol is used to communicate with Chrome and drive...
Browser
Cross-Browser Testing tool

All cross-browser testing tool are web driver based. See the webdriver for more information. You can also open multiple browsers (desktop, mobile for responsive design) and see your change live thanks...
DOM - Environment (Library and Languages)

A DOM environment is a library that implements the DOM API Browser: Standard support with the DOM Web API jquery is a higher interface based on the Javascript Web API but does not provide a DOM...
Browser
Headless Chrome

is a way to run the Chrome browser in a headless mode (ie without the UI, you don't see the screen, it's a server mode) The Chrome Debugging Protocol is an API that permits to control Chrome (or any...
Devtron
Web - Electron

Electron is a framework to create Web Desktop app that is developped around the chrome browser. A Electron app have at minimum the following folder structure: API All APIs...
Browser
Web - Headless browser (Test automation)

A headless browser is an application/library that emulates a web browser but without a graphical user interface ie (without DOM / without the Web api) They are the basis to build a web bot. Build...
Chrome Node Screenshot
Web Page ScreenShot

How to take a screenshot of a web page



Share this page:
Follow us:
Task Runner