#browser-automation #cross-browser-testing #node-js ## Purpose [**webdriverio**](https://www.npmjs.com/package/webdriverio) uses the [[+Selenium architecture#WebDriver standard|WebDriver specification]] for communicating with the browser. But opposed to the official Selenium WebDriver clients/language bindings, it is a comprehensive test framework: It aims to free its users from solving common problems like configuration, parallelization and integration with other services. In that regard, it is similar to [[+Nightwatch]]. ## Documentation entry points - [Official documentation startpage](https://webdriver.io) - [WDIO CLI options](https://webdriver.io/docs/clioptions) - [**wdio-geckodriver-service**](https://github.com/webdriverio-community/wdio-geckodriver-service) - for running Firefox locally without having to use the Selenium Standalone service - [**@wdio/selenium-standalone-service**](https://webdriver.io/docs/selenium-standalone-service/) - for being able to run local browsers without having to install the respective driver binaries. Not needed for Chrome and Firefox when **wdio-chromedriver-service** and **wdio-geckodriver-service** are installed - [Testrunner configuration](https://webdriver.io/docs/configurationfile) ## Modes It can be used in two modes: **Standalone mode** and **testrunner mode**. ### Standalone Mode For **standalone mode**, you only have to install the [**webdriverio**](https://www.npmjs.com/package/webdriverio) package. Feature-wise, this can be compared with the official WebDriver JavaScript bindings: It allows you control a browser, but it does not offer you much convenience. ### Testrunner mode For **testrunner mode**, you have to install the [**@wdio/cli**](https://webdriver.io/docs/clioptions/) package (which includes the webdriverio package as a dependency). In this mode, WebdriverIO comes packed with features like: - Setup utility and configuration management - Test runner (Mocha, Jasmine or Cucumber) - REPL - Something similar to the [promise manager known from the selenium-webdriver package in version 3](http://www.assertselenium.com/selenium/promise-manager-in-webdriverjs/) (can be switched off) - Extra hooks - Services like Chromedriver, Selenium-Standalone, Sauce (Labs), Applitools - Parallelization - Mock/spy functionality - ... and many more ## Architecture [[WebdriverIO architecture]] ## Configuration ### Browsers In the _wdio.conf.js_ (or whatever the configuration file is named), just pass an array of objects to the `capabilities` field. Each of the object should contain the capabilities for the desired browser. Keep in mind that certain setups require the respective `services` to be specified. Here is an example: ```js // wdio.conf.js capabilities: [ { // Local Chrome, headless browserName: "chrome", "goog:chromeOptions": { args: ["--headless"], }, }, { // Local Firefox, headless browserName: "firefox", "moz:firefoxOptions": { args: ["-headless"], }, }, { // Sauce Labs browser browserName: 'safari', platformName: 'macOS 11', browserVersion: 'latest', }, ], services: ["chromedriver", "geckodriver", "sauce"], ``` Sauce Labs capabilities can be looked up in the [[Sauce Labs#^sauce-labs-platform-configurator]]. ## Repository for experiments [https://github.com/systemboogie/explore-webdriverio](https://github.com/systemboogie/explore-webdriverio)