O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JUnit 5 extension for Selenium

In order to simplify the use of Selenium WebDriver in JUnit 5, the open source JUnit 5 extension called selenium-jupiter can be used. This extension has been built using the dependency injection capability provided by the extension model of JUnit 5. Thanks to this feature, different types objects can be injected in JUnit 5 in @Test methods as parameters. Concretely, selenium-jupiter allows to inject subtypes of the WebDriver interface (for example, ChromeDriver, FirefoxDriver, and so on).

Using selenium-jupiter is very easy. First, we need to import the dependency in our project (typically as test dependency). In Maven, it is done as follows:

<dependency>        <groupId>io.github.bonigarcia</groupId> <artifactId>selenium-jupiter</artifactId> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required