• Stars
    star
    2,364
  • Rank 19,455 (Top 0.4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automated driver management and other helper features for Selenium WebDriver in Java

Maven Central Build Status Quality Gate codecov badge-jdk License badge Backers on Open Collective Sponsors on Open Collective Support badge Twitter Follow

WebDriverManager is an open-source Java library that carries out the management (i.e., download, setup, and maintenance) of the drivers required by Selenium WebDriver (e.g., chromedriver, geckodriver, msedgedriver, etc.) in a fully automated manner. In addition, WebDriverManager provides other relevant features, such as the capability to discover browsers installed in the local system, building WebDriver objects (such as ChromeDriver, FirefoxDriver, EdgeDriver, etc.), and running browsers in Docker containers seamlessly.

Documentation

As of version 5, the documentation of WebDriverManager has moved here. This site contains all the features, examples, configuration, and advanced capabilities of WebDriverManager.

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(). The following example shows the skeleton of a test case using JUnit 5, Selenium WebDriver, and WebDriverManager.

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
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 ChromeTest {

    WebDriver driver;

    @BeforeAll
    static void setupAll() {
        WebDriverManager.chromedriver().setup();
    }

    @BeforeEach
    void setup() {
        driver = new ChromeDriver();
    }

    @AfterEach
    void teardown() {
        driver.quit();
    }

    @Test
    void test() {
        // Your test logic here
    }

}

Alternatively, you can use the method create() to manage automatically the driver and instantiate the WebDriver object in a single line. For instance, as follows:

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
    }

}

For further information about the driver resolution algorithm implemented by WebDriverManager and configuration capabilities, read the documentation.

Browsers in Docker

Another relevant new feature available in WebDriverManager 5 is the ability to create browsers in Docker containers out of the box. The requirement to use this feature is to have installed a Docker Engine in the machine running the tests. 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, starts the container, and instantiates the WebDriver object to use it. The following test shows a simple example using Chrome in Docker. This example also enables the recording of the browser session and remote access using noVNC:

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
    }

}

Support

WebDriverManager is part of OpenCollective, an online funding platform for open and transparent communities. You can support the project by contributing as a backer (i.e., a personal donation or recurring contribution) or as a sponsor (i.e., a recurring contribution by a company).

Backers

Sponsors

Alternatively, you can acknowledge my work by buying me a coffee:



About

WebDriverManager (Copyright © 2015-2023) is a project created and maintained by Boni Garcia and licensed under the terms of the Apache 2.0 License.

If you like my work, please consider nominating me for the GitHub Stars program.

More Repositories

1

mastering-junit5

Examples of the Packt book "Mastering Software Testing with JUnit 5"
Java
363
star
2

selenium-jupiter

JUnit 5 extension for Selenium WebDriver
Java
225
star
3

dualsub

DualSub: bilingual subtitles maker
Java
172
star
4

selenium-webdriver-java

Examples of the O'Reilly book "Hands-On Selenium WebDriver with Java"
Java
111
star
5

webdrivermanager-examples

JUnit tests with Selenium WebDriver and WebDriverManager
Java
111
star
6

rate-my-cat

Sample application for the book "Mastering Software Testing with JUnit 5"
Java
25
star
7

novnc

Standalone noVNC client based on Alpine
Dockerfile
21
star
8

web-programming-examples

Examples of web applications using Java and Angular, among other technologies
HTML
20
star
9

bonigarcia.github.io

Personal web page of Boni García
JavaScript
16
star
10

webgl-examples

webgl-examples
HTML
13
star
11

webdrivermanager-spring-boot

Basic project with JUnit tests using Spring-Boot, Selenium WebDriver and WebDriverManager
Java
11
star
12

selenium-jupiter-examples

Test examples using Selenium-Jupiter, Selenium WebDriver, and JUnit 5
Java
10
star
13

webdrivermanager-basic

Basic project with JUnit tests using Selenium Webdriver and WebDriverManager
Java
8
star
14

browserwatcher

Browser extension for console monitoring, tab recording, Content Security Policy (CSP) disabling, and JavaScript/CSS injection
Java
8
star
15

rust-examples

Small programs written in Rust. Warm up for the upcoming Selenium Manager
Rust
7
star
16

android-examples

Sample Android apps created with Java
Java
5
star
17

selenium-jupiter-webrtc

Tests for WebRTC applications using Selenium-Jupiter
Java
5
star
18

android-basic-app

Basic Android app developed with Java
Java
5
star
19

c-examples

Basic C examples
C
4
star
20

react-native-examples

Basic apps using React Native
JavaScript
3
star
21

wdm-agent-example

Example of maven project using Selenium WebDriver and WebDriverManager as Agent
Java
3
star
22

job-tracker

Scheduled automated test for daily tracking jobs about Selenium, Cypress, Puppeteer, and Playwright on Linkedin
Java
3
star
23

test-orchestration

Jenkins library for test orchestration
Groovy
3
star
24

spark-examples

Collection of Spark examples using Python
Python
2
star
25

nodejs-examples

Node.js examples
JavaScript
2
star
26

git-intro

2
star
27

bonigarcia

Visiting Professor @UC3M, Staff Software Engineer @saucelabs, Committer @SeleniumHQ
1
star
28

nlp-examples

Natural Language Processing (NLP) examples with Python
Jupyter Notebook
1
star
29

saucelabs-fat-jars

Basic projects to illustrate how to create fat-jars with Maven and Gradle
Java
1
star
30

genai-selenium

GenAI-assisted development of Selenium tests
Java
1
star
31

nubomedia-test

NUBOMEDIA application example
Java
1
star