This repository contains a basic project with JUnit tests using Spring Boot, Selenium WebDriver and WebDriverManager. This code is open source, released under the terms of Apache 2.0 License.
In order to use WebDriverManager from tests in a Maven project, you need to add the following dependency in your pom.xml
(Java 8 or upper required):
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>${wdm.version}</version>
<scope>test</scope>
</dependency>
... or in Gradle project:
dependencies {
testImplementation("io.github.bonigarcia:webdrivermanager:${wdm.version}")
}
Then you can let WebDriverManager to do manage WebDriver binaries for your application/test. For example, as a JUnit test using Chrome browser:
public class ChromeTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
@Before
public void setupTest() {
driver = new ChromeDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
// Your test code here
}
}
... and using Firefox:
public class FirefoxTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
WebDriverManager.firefoxdriver().setup();
}
@Before
public void setupTest() {
driver = new FirefoxDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
// Your test code here
}
}
If you have questions on how to use WebDriverManager properly with a special configuration or suchlike, please consider asking a question on Stack Overflow and tag it with webdrivermanager-java.
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).
WebDriverManager (Copyright © 2015-2023) is a project created and maintained by Boni Garcia licensed under Apache 2.0 License.