{"id":21175228,"url":"https://github.com/alb-i986/selenium-junit4","last_synced_at":"2026-06-19T01:31:28.717Z","repository":{"id":150289811,"uuid":"59307092","full_name":"alb-i986/selenium-junit4","owner":"alb-i986","description":" (Work In Progress) A light-weight Selenium framework providing a number of JUnit Rules which cover, among the others: setup and teardown of a WebDriver, screenshots in case of failure.","archived":false,"fork":false,"pushed_at":"2016-07-11T07:01:55.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-30T04:49:04.779Z","etag":null,"topics":["junit","selenium"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alb-i986.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-20T15:51:28.000Z","updated_at":"2017-02-16T23:32:42.000Z","dependencies_parsed_at":"2023-04-29T15:01:56.939Z","dependency_job_id":null,"html_url":"https://github.com/alb-i986/selenium-junit4","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alb-i986/selenium-junit4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alb-i986%2Fselenium-junit4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alb-i986%2Fselenium-junit4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alb-i986%2Fselenium-junit4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alb-i986%2Fselenium-junit4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alb-i986","download_url":"https://codeload.github.com/alb-i986/selenium-junit4/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alb-i986%2Fselenium-junit4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34514282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["junit","selenium"],"created_at":"2024-11-20T16:57:38.038Z","updated_at":"2026-06-19T01:31:28.687Z","avatar_url":"https://github.com/alb-i986.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Selenium-JUnit4\n\nA light-weight Selenium testing framework providing a number of features in the form of\n[JUnit Rules](https://github.com/junit-team/junit4/wiki/Rules).\n\n\n## Motivation\nWhen starting a test automation project using Selenium, there are a few things that need to be\nimplemented.\nIn fact, there's a gap to fill between Selenium and the testing framework of choice.\nA classic example is the setup and tear down of a `WebDriver` for each test.\nOr to take a screenshot in case of test failure. Selenium provides a method for taking a screenshot,\nbut it's up to the tester to call it when a test fails.\nAll of these things are pretty much a must-have, so we all (testers) end up reinventing the wheel.\n\nThe aim of this project is to fill the gap for projects using JUnit as the testing framework.\nThe way it does is by exploiting [JUnit Rules](https://github.com/junit-team/junit4/wiki/Rules),\nwhich by the way allows for a *clean* design.\n\n\n## Features\n\n- Automatic setup and tear down of `WebDriver`'s\n- Retry flaky tests in case of failure\n\nSoon to be added:\n\n- Screenshot on test failure\n- HTML test reports (with screenshots on test failure)\n\n\n## Example of usage\n\n    public class MySeleniumTest {\n\n       @Rule\n       public final SeleniumRule seleniumRule = new SeleniumRule(new ChromeDriverFactory())\n           .toRetryFlakyTestsOnFailure(2); // retry each test max 2 times (max 3 executions in total)\n\n       protected final WebDriver driver() {\n           return seleniumRule.getDriver();\n       }\n\n       @Test\n       @Flaky // without this, the test will *not* be re-tried in case of failure, even though SeleniumRule was configured to retry\n       public void myFlakyTest() {\n           throw new RuntimeException(\"flaky test failure\");\n       }\n\n       @Test\n       public void myStableTest() {\n           driver().get(\"http://www.google.com\");\n           driver().findElement(By.name(\"q\")).sendKeys(\"selenium-junit\" + Keys.ENTER);\n           new WebDriverWait(driver(), 5).until(ExpectedConditions.titleContains(\"selenium-junit\"));\n       }\n\n       private static class ChromeDriverFactory implements WebDriverFactory {\n           @Override\n           public WebDriver create() {\n               return new ChromeDriver();\n           }\n       }\n    }\n\nIn this example we have a test class with two tests, `myStableTest` and `myFlakyTest`,\nand one Rule, a `SeleniumRule`.\n\nIn `myStableTest` we are using the driver returned by `seleniumRule.getDriver()`\n(which, for convenience, is wrapped in the method `driver()`)\nto interact with the web UI of the System Under Test.\nThanks to `SeleniumRule`, the driver has already been initialized\n(in this example, it will be a local instance of the browser Chrome),\nand it will also be torn down automatically as soon as the test finishes.\n\n`myFlakyTest` is simulating a flaky test by always throwing an exception.\nSince the test is annotated with `@Flaky`, and `SeleniumRule` is configured to retry flaky tests\non failure (`.toRetryFlakyTestsOnFailure(2)`), then `myFlakyTest` will be executed 3 times\n(1 standard execution + 2 retries, as per configuration).\n\nAll of the details regarding the setup/teardown and the retry logic are hidden behind three lines:\n\n    @Rule\n    public final SeleniumRule seleniumRule = new SeleniumRule(new ChromeDriverFactory())\n       .toRetryFlakyTestsOnFailure(2); // retry each test max 2 times (max 3 executions in total)\n\n`SeleniumRule` is the one and only class being part of the public API of this project.\nIt can be configured so that users can get only the features they need.\nThe most minimal configuration includes only the setup and tear down of a WebDriver:\n\n    @Rule\n    public final SeleniumRule seleniumRule = new SeleniumRule(new ChromeDriverFactory());\n\nPlease see the javadoc of `SeleniumRule` for an up-to-date example of usage.\n\n\n## Internals\n\nInternally, `SeleniumRule` is not a monolithic Rule implementing all of the features.\nRather, each feature is implemented by a `TestRule` on its own.\n`SeleniumRule` simply acts as a collector (a `RuleChain`) of the rules configured:\n\n- makes sure the sub-rules are run in the correct order\n- provides clients with a configuration API to activate only the features, aka sub-rules, needed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falb-i986%2Fselenium-junit4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falb-i986%2Fselenium-junit4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falb-i986%2Fselenium-junit4/lists"}