Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

License

NotificationsYou must be signed in to change notification settings

bonigarcia/webdrivermanager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven CentralBuild StatusQuality Gatecodecovbadge-jdkLicense badgeBackers on Open CollectiveSponsors on Open CollectiveSupport badgeTwitter Follow

WebDriverManager is an open-source Java library that carries out the management (i.e., download, setup, and maintenance) of the drivers required bySelenium 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 asChromeDriver,FirefoxDriver,EdgeDriver, etc.), and running browsers in Docker containers seamlessly.

Documentation

As of version 5, the documentation of WebDriverManager has movedhere. 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 methodsetup(). The following example shows the skeleton of a test case usingJUnit 5,Selenium WebDriver, andWebDriverManager.

importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.BeforeAll;importorg.junit.jupiter.api.BeforeEach;importorg.junit.jupiter.api.Test;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.chrome.ChromeDriver;importio.github.bonigarcia.wdm.WebDriverManager;classChromeTest {WebDriverdriver;@BeforeAllstaticvoidsetupAll() {WebDriverManager.chromedriver().setup();    }@BeforeEachvoidsetup() {driver =newChromeDriver();    }@AfterEachvoidteardown() {driver.quit();    }@Testvoidtest() {// Your test logic here    }}

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

importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.BeforeEach;importorg.junit.jupiter.api.Test;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.chrome.ChromeDriver;importio.github.bonigarcia.wdm.WebDriverManager;classChromeCreateTest {WebDriverdriver;@BeforeEachvoidsetup() {driver =WebDriverManager.chromedriver().create();    }@AfterEachvoidteardown() {driver.quit();    }@Testvoidtest() {// Your test logic here    }}

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

Browsers in Docker

Another relevant new feature available in WebDriverManager 5 is the ability to create browsers inDocker containers out of the box. The requirement to use this feature is to have installed aDocker Engine in the machine running the tests. To use it, we need to invoke the methodbrowserInDocker() in conjunction withcreate() of a given manager. This way, WebDriverManager pulls the image fromDocker 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 usingnoVNC:

importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.BeforeEach;importorg.junit.jupiter.api.Test;importorg.openqa.selenium.WebDriver;importio.github.bonigarcia.wdm.WebDriverManager;classDockerChromeVncTest {WebDriverdriver;WebDriverManagerwdm =WebDriverManager.chromedriver().browserInDocker()            .enableVnc().enableRecording();@BeforeEachvoidsetup() {driver =wdm.create();    }@AfterEachvoidteardown() {wdm.quit();    }@Testvoidtest() {// Your test logic here    }}

Support

WebDriverManager is part ofOpenCollective, an online funding platform for open and transparent communities. You can support the project by contributing as a backer (i.e., a personaldonation orrecurring contribution) or as asponsor (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-2025) is a project created and maintained byBoni Garcia and licensed under the terms of theApache 2.0 License.


[8]ページ先頭

©2009-2025 Movatter.jp