{"id":15199839,"url":"https://github.com/willhaben/willtest","last_synced_at":"2025-10-02T15:30:29.068Z","repository":{"id":17523983,"uuid":"80122271","full_name":"willhaben/willtest","owner":"willhaben","description":"An easy way to set up and use Selenium WebDriver in your JUnit tests","archived":true,"fork":false,"pushed_at":"2022-01-04T16:32:40.000Z","size":6462,"stargazers_count":7,"open_issues_count":4,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-25T01:31:53.847Z","etag":null,"topics":["java","java-8","junit","junit4","selenium-java","selenium-webdriver"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willhaben.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-26T14:37:04.000Z","updated_at":"2023-02-10T14:01:25.000Z","dependencies_parsed_at":"2022-07-26T18:15:08.443Z","dependency_job_id":null,"html_url":"https://github.com/willhaben/willtest","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willhaben%2Fwilltest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willhaben%2Fwilltest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willhaben%2Fwilltest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willhaben%2Fwilltest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willhaben","download_url":"https://codeload.github.com/willhaben/willtest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219875716,"owners_count":16554705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","java-8","junit","junit4","selenium-java","selenium-webdriver"],"created_at":"2024-09-28T02:03:35.621Z","updated_at":"2025-10-02T15:30:23.474Z","avatar_url":"https://github.com/willhaben.png","language":"HTML","readme":"# willtest\n\n[![Build Status](https://travis-ci.org/willhaben/willtest.svg?branch=master)](https://travis-ci.org/willhaben/willtest)\n[![Maven Central](https://img.shields.io/maven-central/v/at.willhaben.willtest/core)](https://mvnrepository.com/artifact/at.willhaben.willtest)\n\nDo not edit this file. See [this](https://github.com/willhaben/willtest#update-the-documentation) for instructions.\n\n## Overview\nWilltest makes integrating JUnit and Selenium easier with providing a set of \n[JUnit Extension](https://junit.org/junit5/docs/current/user-guide/#extensions) and other utility classes which let you \ncomplete tasks like:\n* Managing lifecycle of WebDriver instances\n* Reporting capabilities like saving logs, screenshots and HTML source\n* Fetching information from javascript alerts and errors\n* Supporting uploading of any file from file system or classpath\n* Abstract PageObject with some common functions\n* Main browsers are supported (Firefox, Chrome, Edge, InternetExplorer)\n* Support for mobile tests with appium (Android, iOS)\n\n## Requirements\n* Currently Selenium with version [3.141.59] is used\n* JUnit 5 with version [5.7.0] is used\n\n## Getting Started\nThe code is built up from several small building blocks. Only the ```core``` module is needed to start\nwriting browser tests. Nevertheless the ```misc``` module will speed up development with some helper classes\nand an abstract ```PageObject``` which can be extended.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eat.willhaben.willtest\u003c/groupId\u003e\n    \u003cartifactId\u003ecore\u003c/artifactId\u003e\n    \u003cversion\u003e3.1.9\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eat.willhaben.willtest\u003c/groupId\u003e\n    \u003cartifactId\u003emisc\u003c/artifactId\u003e\n    \u003cversion\u003e3.1.9\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n[Geckodriver](https://github.com/mozilla/geckodriver/releases) is also needed to run a test with Firefox + Selenium.\nThe path of the geckodriver executable is expected in the [webdriver.gecko.driver](http://learn-automation.com/use-firefox-selenium-using-geckodriver-selenium-3/) \nsystem property. An [automated way](https://github.com/webdriverextensions/webdriverextensions-maven-plugin)\nis shown in the [POM of the examples module](https://github.com/willhaben/willtest/blob/master/examples/pom.xml).\nIt downloads and applies the geckodriver and chromedriver in the surefire settings.\n\nNow the environment is ready to be used like this:\n\n```java\n@ExtendWith(DriverParameterResolverExtension.class)\n@BrowserUtil({ScreenshotProvider.class, PageSourceProvider.class})\nclass FirstExample {\n\n    private static final String REPO_HEADER_LOCATOR = \"div.repohead-details-container h1\";\n    private static final String WILLTEST_GITHUB_PAGE = \"https://github.com/willhaben/willtest\";\n\n    @Test\n    // The started WebDriver will be injected in the test method parameter\n    void openPage(WebDriver driver) {\n        driver.get(WILLTEST_GITHUB_PAGE);\n        WebElement element = driver.findElement(By.cssSelector(REPO_HEADER_LOCATOR));\n        assertThat(element.getText(), is(\"willhaben/willtest\"));\n    }\n\n    @Test\n    void buggyTest(WebDriver driver) {\n        driver.get(WILLTEST_GITHUB_PAGE);\n        WebElement element = driver.findElement(By.cssSelector(REPO_HEADER_LOCATOR));\n        assertThat(element.getText(), is(\"fooooo\"));\n    }\n}\n```\n\nIf the test class is executed (it can be found in the examples module) a screenshot and \nan HTML source are automatically saved into the surefire reports, in case of the ```buggyTest``` method. \nThis is done by the Willtest framework when you specify the two provider classes in the ```@BrowserUtil```\nannotation.\n\n## Recipes\nAll the code examples below can be found in the examples maven submodule.\n\n### Using Selenium HUB to run Firefox\n\nBy default the willtest framework will start a local firefox instance to run the tests. If this behaviour \nneeds to be changed there are some properties to change this.\n\n|name|description|default|possible|\n|---|---|---|---|\n|browser|Select which browser should be started|```firefox```|```firefox```, ```chrome```, ```ie```, ```edge```|\n|remote|Execute tests locally or on a selenium grid|```false```|```false```, ```true```|\n|seleniumHub|Specify the url to the selenium grid or remote browser|EMPTY|```http://sel-grid:1234/wd/hub```|\n\n### PageObject\nTo write tests with the page-object-pattern you can use the provided ```PageObject``` as a base\nclass. It provides some commonly needed functions to improve the readability of your page objects and tests.\nEvery method is documented in JavaDoc.\n\n### Customization options\nExtending the willtest framework is done with the ```@BrowserUtil``` annotation. There are multiple interfaces\nwhich can be implemented to change the behaviour of the framework. The annotation can be used on class and method level.\nThe method level will override the class level one.\n\n#### Browseroptions\nThe browser options and capabilities can be modified by implementing the ```Optionmodifier``` interface.\n\n```java\npublic class BrowserSetup implements OptionModifier {\n    \n    @Override\n    public ChromeOptions modifyChromeOptions(ChromeOptions options) {\n        options.merge(getDesiredCapabilities(\"chrome\"));\n        options.addArguments(\"--start-maximized\");\n        return options;\n    }\n\n    public DesiredCapabilities getDesiredCapabilities(String nameOfBrowser) {\n        DesiredCapabilities capabilities = new DesiredCapabilities();\n        capabilities.setCapability(\"applicationCacheEnabled\", false);\n        capabilities.setJavascriptEnabled(true);\n        capabilities.setBrowserName(nameOfBrowser);\n        return capabilities;\n    }\n}\n\n// ad the class to the test\n@ExtendWith(DriverParameterResolverExtension.class)\n@BrowserUtil(BrowserSetup.class)\nclass FirstExample {}\n```\n\n#### Webdriver modifications\nIf you need to modify the ```WebDriver``` (e.g. maximise the browser) the ```WebDriverPostInterceptor``` interface \ncan be used.\n\n```java\npublic class PostProcessSetup implements WebDriverPostInterceptor {\n    @Override\n    public void postProcessWebDriver(WebDriver driver) {\n        driver.manage().window().maximize();\n    }\n}\n\n// ad the class to the test\n@ExtendWith(DriverParameterResolverExtension.class)\n@BrowserUtil(PostProcessSetup.class)\nclass FirstExample {}\n```\n\n#### On failure behaviour\nWhen you need to clear up resources or signal a test failure then the interface ```FailureListener``` must be used.\n\n### File Upload\nThe Willtest framework configures by default a simple way to upload any file from the filesystem or from the classpath.\nFiles from jars on the classpath are also supported. It does not matter if your test runs in a local browser, or in\na Selenium HUB.\n\nUploading a simple file is that simple:\n\n```java\nhtmlInputElementWithFileType.sendKeys(pathToFile);\n```\n\nUploading a classpath resource is slightly more complicated. It is necessary to copy the file to a temp directory\nand use this path with the ```sendKeys``` method. The TempDirectory extension from \n[Junit Pioneer](https://junit-pioneer.org/) can be used for this.\n \n## Asserting browser request\nFor testing browser requests and asserting against them it is possible to start a \n[browsermob-proxy](https://github.com/lightbody/browsermob-proxy) alongside the test.\nThis can be done by specifying the ```ProxyWrapper``` class as test method parameter. The framework checks the test\nmethod parameters and automatically starts the proxy and injects the parameter.\n\n```java\n@ExtendWith(DriverParameterResolverExtension.class)\nclass ProxyExample {\n\n    private static final Logger LOGGER = LoggerFactory.getLogger(ProxyExample.class);\n\n    @Test\n    void createProxyAndCaptureRequest(WebDriver driver, ProxyWrapper proxyWrapper) {\n        proxyWrapper.getProxy().enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);\n        proxyWrapper.getProxy().newHar();\n        driver.get(\"https://www.google.com\");\n        proxyWrapper.getProxy().getHar()\n                .getLog()\n                .getEntries()\n                .stream()\n                .map(HarEntry::getRequest)\n                .forEach(request -\u003e {\n                    LOGGER.info(request.getUrl());\n                });\n    }\n}\n```\n\n## Screenshot settings\nIf the site has a fixed top bar it is possible to provide a custom ```ShootingStrategy``` to cut this out on the\nscreenshot. See the ```ScreenshotProviderExample```.\n\n## Allure\nIf you want to use allure reporting, add all dependencies (see the [allure-java github page](https://github.com/allure-framework/allure-java)) to your repository and call the mvn install or test with `-Dallure=true`.\nScreenshots will be added automatically if you use them.\n\n## Contribution\nWillhaben accepts pull requests or other type of feedback. We do our best to reply in a short period of time.\n\n## Update the documentation\nDo not edit the *README.md* because it is auto generated. Use the *readme-md-template.md* file and run a\n```mvn clean process-resources``` or ```mvn clean install```. This is used to inject maven properties like the current\nversion in the README.\n\n## License\nMIT, Copyright (c) 2021 willhaben internet service GmbH \u0026 Co KG\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillhaben%2Fwilltest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillhaben%2Fwilltest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillhaben%2Fwilltest/lists"}