**Last Update**: 26.11.2023
***
> [!NOTE]
> [Selenium Manager](https://www.selenium.dev/documentation/selenium_manager/) is the official driver manager of the Selenium project, and it is shipped out of the box with every Selenium release.
### Setup
Maven:
```xml
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
```
Gradle:
```groovy
dependencies {
testImplementation("io.github.bonigarcia:webdrivermanager:5.6.2")
}
```
### Driver Management
>The primary use of WebDriverManager is the automation of driver management. For using this feature, you need to select a given manager in the WebDriverManager API (e.g., `chromedriver()` for Chrome) and invoke the method `setup()`.
```java
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
class ChromeCreateTest {
WebDriver driver;
@BeforeEach
void setup() {
driver = WebDriverManager.chromedriver().create();
}
@AfterEach
void teardown() {
driver.quit();
}
@Test
void test() {
// Your test logic here
}
}
```
### Browsers in Docker
> Another relevant new feature available in WebDriverManager 5 is the ability to create browsers in [Docker](https://www.docker.com/) containers out of the box. To use it, we need to invoke the method `browserInDocker()` in conjunction with `create()` of a given manager. This way, WebDriverManager pulls the image from [Docker Hub](https://hub.docker.com/), starts the container, and instantiates the WebDriver object to use it.
```java
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
class DockerChromeVncTest {
WebDriver driver;
WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker()
.enableVnc().enableRecording();
@BeforeEach
void setup() {
driver = wdm.create();
}
@AfterEach
void teardown() {
wdm.quit();
}
@Test
void test() {
// Your test logic here
}
}
```
***
**References**:
- [Github WebDriverManager](https://github.com/bonigarcia/webdrivermanager)
- [WebDriverManager official documentation](https://bonigarcia.dev/webdrivermanager/)