Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status Maven Central

Do not edit this file. See this for instructions.


Willtest makes integrating JUnit and Selenium easier with providing a set of JUnit Extension and other utility classes which let you complete tasks like:

  • Managing lifecycle of WebDriver instances
  • Reporting capabilities like saving logs, screenshots and HTML source
  • Fetching information from javascript alerts and errors
  • Supporting uploading of any file from file system or classpath
  • Abstract PageObject with some common functions
  • Main browsers are supported (Firefox, Chrome, Edge, InternetExplorer)
  • Support for mobile tests with appium (Android, iOS)


  • Currently Selenium with version [3.141.59] is used
  • JUnit 5 with version [5.7.0] is used

Getting Started

The code is built up from several small building blocks. Only the core module is needed to start writing browser tests. Nevertheless the misc module will speed up development with some helper classes and an abstract PageObject which can be extended.


Geckodriver is also needed to run a test with Firefox + Selenium. The path of the geckodriver executable is expected in the webdriver.gecko.driver system property. An automated way is shown in the POM of the examples module. It downloads and applies the geckodriver and chromedriver in the surefire settings.

Now the environment is ready to be used like this:

@BrowserUtil({ScreenshotProvider.class, PageSourceProvider.class})
class FirstExample {

    private static final String REPO_HEADER_LOCATOR = "div.repohead-details-container h1";
    private static final String WILLTEST_GITHUB_PAGE = "";

    // The started WebDriver will be injected in the test method parameter
    void openPage(WebDriver driver) {
        WebElement element = driver.findElement(By.cssSelector(REPO_HEADER_LOCATOR));
        assertThat(element.getText(), is("willhaben/willtest"));

    void buggyTest(WebDriver driver) {
        WebElement element = driver.findElement(By.cssSelector(REPO_HEADER_LOCATOR));
        assertThat(element.getText(), is("fooooo"));

If the test class is executed (it can be found in the examples module) a screenshot and an HTML source are automatically saved into the surefire reports, in case of the buggyTest method. This is done by the Willtest framework when you specify the two provider classes in the @BrowserUtil annotation.


All the code examples below can be found in the examples maven submodule.

Using Selenium HUB to run Firefox

By default the willtest framework will start a local firefox instance to run the tests. If this behaviour needs to be changed there are some properties to change this.

name description default possible
browser Select which browser should be started firefox firefox, chrome, ie, edge
remote Execute tests locally or on a selenium grid false false, true
seleniumHub Specify the url to the selenium grid or remote browser EMPTY http://sel-grid:1234/wd/hub


To write tests with the page-object-pattern you can use the provided PageObject as a base class. It provides some commonly needed functions to improve the readability of your page objects and tests. Every method is documented in JavaDoc.

Customization options

Extending the willtest framework is done with the @BrowserUtil annotation. There are multiple interfaces which can be implemented to change the behaviour of the framework. The annotation can be used on class and method level. The method level will override the class level one.


The browser options and capabilities can be modified by implementing the Optionmodifier interface.

public class BrowserSetup implements OptionModifier {
    public ChromeOptions modifyChromeOptions(ChromeOptions options) {
        return options;

    public DesiredCapabilities getDesiredCapabilities(String nameOfBrowser) {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("applicationCacheEnabled", false);
        return capabilities;

// ad the class to the test
class FirstExample {}

Webdriver modifications

If you need to modify the WebDriver (e.g. maximise the browser) the WebDriverPostInterceptor interface can be used.

public class PostProcessSetup implements WebDriverPostInterceptor {
    public void postProcessWebDriver(WebDriver driver) {

// ad the class to the test
class FirstExample {}

On failure behaviour

When you need to clear up resources or signal a test failure then the interface FailureListener must be used.

File Upload

The Willtest framework configures by default a simple way to upload any file from the filesystem or from the classpath. Files from jars on the classpath are also supported. It does not matter if your test runs in a local browser, or in a Selenium HUB.

Uploading a simple file is that simple:


Uploading a classpath resource is slightly more complicated. It is necessary to copy the file to a temp directory and use this path with the sendKeys method. The TempDirectory extension from Junit Pioneer can be used for this.

Asserting browser request

For testing browser requests and asserting against them it is possible to start a browsermob-proxy alongside the test. This can be done by specifying the ProxyWrapper class as test method parameter. The framework checks the test method parameters and automatically starts the proxy and injects the parameter.

class ProxyExample {

    private static final Logger LOGGER = LoggerFactory.getLogger(ProxyExample.class);

    void createProxyAndCaptureRequest(WebDriver driver, ProxyWrapper proxyWrapper) {
        proxyWrapper.getProxy().enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
                .forEach(request -> {

Screenshot settings

If the site has a fixed top bar it is possible to provide a custom ShootingStrategy to cut this out on the screenshot. See the ScreenshotProviderExample.


If you want to use allure reporting, add all dependencies (see the allure-java github page) to your repository and call the mvn install or test with -Dallure=true. Screenshots will be added automatically if you use them.


Willhaben accepts pull requests or other type of feedback. We do our best to reply in a short period of time.

Update the documentation

Do not edit the because it is auto generated. Use the file and run a mvn clean process-resources or mvn clean install. This is used to inject maven properties like the current version in the README.


MIT, Copyright (c) 2021 willhaben internet service GmbH & Co KG