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

About

A WebDriver is a application that control / drive real browsers.

Each browser is backed by a specific WebDriver implementation, called a driver. The drivers for Chrome, Firefox, and Microsoft's IE and Edge web browsers are all standalone executables.

You interact with a device, with a database via a driver.

With a webdriver, you interact with a browsers

It was at first developped by selenium.

They are now standardized via the WebDriver API 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

Library

Selenium

selenium was the first to introduce webdriver and supports many language (Java, Python, Javascript, …)

Others

All others library are wrapper around the WebDriver protocol (ie they start a browser with webdriver)

List:

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

Chrome

ChromeDriver is a standalone server which implements WebDriver's wire protocol for Chromium. It is being developed by members of the Chromium and WebDriver teams. More https://sites.google.com/a/chromium.org/chromedriver/

C:\Users\gerardnico\.cache\selenium\chromedriver\win32\87.0.4280.88>chromedriver.exe
Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/[email protected]{#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.

Specification

Documentation / Reference


Powered by ComboStrap