Headless browser - WebDriver / ChromeDriver (automated testing - W3C WebDriver API)
Table of Contents
1 - About
A WebDriver is a selenium library that control browsers and therefore making automated testing of web apps.
It provides capabilities for:
- navigating to web pages,
- user input,
- JavaScript execution,
- and more.
A WebDriver uses browser APIs to control the browser and run tests.
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 drivers for Chrome, Firefox, and Microsoft's IE and Edge web browsers are all standalone executables that should be placed on your system PATH.
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/
same as http://webdriver.io/ ?
2 - Articles Related
3 - 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.
4 - API / DSL
Code:
5 - Testing
6 - Driver
7 - 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();
}
})();
8 - Chrome
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.
9 - Library
- node: Nightwatch - Npm Selenium binding library - End-to-end testing
- java: WebDriverManager (Driver are located at ~/.cache/selenium)
- Cloud (Remote): https://docs.browserless.io/