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();
}
})();
List
The drivers are all server executables:
- for Chrome: chromedriver
- for Firefox: geckodriver
- for Microsoft's IE and Edge web browsers
- and more 4)
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
- java: WebDriverManager (Driver are located at ~/.cache/selenium)
Specification
- W3C WebDriver API / https://www.w3.org/TR/webdriver1/ (formerly