{"id":23342387,"url":"https://github.com/harmin-parra/report4s","last_synced_at":"2025-10-28T19:31:06.849Z","repository":{"id":158816997,"uuid":"368327455","full_name":"harmin-parra/report4s","owner":"harmin-parra","description":"Selenium HTML reporter for the TestNG framework. Can automatically log screenshots upon webdriver events.","archived":false,"fork":false,"pushed_at":"2024-04-14T07:45:43.000Z","size":75211,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T00:32:44.843Z","etag":null,"topics":["selenium","selenium-java","testng","webtest","webtesting"],"latest_commit_sha":null,"homepage":"","language":"Java","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/harmin-parra.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"custom":["https://www.buymeacoffee.com/harmin"]}},"created_at":"2021-05-17T21:34:56.000Z","updated_at":"2023-11-04T00:35:33.000Z","dependencies_parsed_at":"2023-10-16T10:40:52.084Z","dependency_job_id":"21413bc3-0e85-4663-98ec-0b665ba01865","html_url":"https://github.com/harmin-parra/report4s","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmin-parra%2Freport4s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmin-parra%2Freport4s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmin-parra%2Freport4s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmin-parra%2Freport4s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harmin-parra","download_url":"https://codeload.github.com/harmin-parra/report4s/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238702916,"owners_count":19516488,"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":["selenium","selenium-java","testng","webtest","webtesting"],"created_at":"2024-12-21T05:14:26.431Z","updated_at":"2025-10-28T19:31:00.016Z","avatar_url":"https://github.com/harmin-parra.png","language":"Java","funding_links":["https://www.buymeacoffee.com/harmin"],"categories":[],"sub_categories":[],"readme":"If you like this software, consider contributing to the project through [buy me a coffee](https://www.buymeacoffee.com/harmin)\n      \n# Report4s\n\nSimple and yet elegant Selenium HTML report.\n\nReport4s is a Selenium HTML reporter for the TestNG framework.\n\nIt is only compatible with Selenium 4 or later.\n\n\n## Features\n\n + Can automatically log screenshots upon the following webdriver events:\n    + `Select.deselectByIndex(int)`\n    + `Select.deselectByValue(java.lang.String)`\n    + `Select.deselectByVisibleText(java.lang.String)`\n    + `Select.selectByIndex(int)`\n    + `Select.selectByValue(java.lang.String)`\n    + `Select.selectByVisibleText(java.lang.String)`\n    + `WebDriver.get(java.lang.String)`\n    + `WebDriver.navigate().back()`\n    + `WebDriver.navigate().forward()`\n    + `WebDriver.navigate().refresh()`\n    + `WebDriver.navigate().to(java.lang.String)`\n    + `WebDriver.navigate().to(java.net.URL)`\n    + `WebElement.click()`\n    + `WebElement.sendKeys(CharSequence[])`\n\n + The stack trace of exceptions are also logged in order to facilitate error analysis.\n\n + Different screenshot gathering strategies are supported:\n    + `all`     Screenshot of all intercepted webdriver events.\n    + `last`    The last screenshot of each @Test annotated methods.\n    + `failed`  The last screenshot of each test failure.\n    + `manual`  Deactivation of automatic screenshot gathering except for the last step of failed tests.\n\n\n## The ZIP file contents\n\n```\nreport4.zip\n|---javadoc                    The API documentation\n|---report4s.properties        Configuration file (optional)\n|---lib                        Required external libraries\n    |---report4s.jar\n    |---commons-io-2.12.0.jar\n    |---commons-lang3-3.12.0.jar\n```\n\n\n## Requirements\nJava 11 or 17\n\ntestng 7.8.0 or later\n\nSelenium 4.10.0 or later\n\n\n## Caution\nDo not rename the report4s JAR file.\n\n\n## Installation\nAdd the JAR files to the classpath.\n\nAdd `report4s.properties` file in your project root folder (optional).\n\n\n## TestNG XML file configuration\nAdd the following lines before the closing `\u003c/suite\u003e` tag in your testng XML file :\n\n```\n\u003c!DOCTYPE suite SYSTEM \"http://testng.org/testng-1.0.dtd\" \u003e\n\u003csuite name=\"...\" \u003e\n    ...\n    ...\n    \u003clisteners\u003e\n        \u003clistener class-name=\"com.github.report4s.Listeners\" /\u003e\n    \u003c/listeners\u003e\n\u003c/suite\u003e \n```\n\n\n## The packages to import\n\n```\nimport com.github.report4s.*;\n```\n\nor\n\n```\nimport com.github.report4s.DriverListener;\nimport com.github.report4s.Report4s;\nimport com.github.report4s.Level;\n```\n\n\n## The test configuration\n\nThe WebDriver needs to be decorated with a WebDriver listener.\n\n```\nimport com.github.report4s.DriverListener;\n\npublic class MyTest {\n \n    private WebDriver driver;\n    \n    @BeforeSuite(alwaysRun=true)\n    public void setUp() {\n        WebDriver raw_driver;\n        \n        // Initialize raw_driver as instance of FirefoxDriver, or ChromeDriver, or EdgeDriver, etc.\n        \n        DriverListener listener = new DriverListener();\n        this.driver = new EventFiringDecorator\u003cWebDriver\u003e(listener).decorate(raw_driver);\n        this.driver.manage().window().maximize();\n    }\n\n    // Your @Test annotated methods go here.\n    \n    @AfterSuite\n    public void tearDown() {\n        try { this.driver.quit(); }\n        catch (Exception e) { }\n    }   \n}\n```\n\n\n## Screenshot gathering strategies\n\nThere are three strategies:\n+ `all`     Screenshot for each intercepted webdriver event. This is the default value.\n+ `last`    Screenshot of the last step for each `@Test` annotated method.\n+ `failed`  Screenshot of the last step for each failed test.\n+ `manual`  Deactivation of automatic screenshot gathering except for the last step of failed tests. \n\nRegardless of the strategy, additional screenshots can be loggged manually alongside a description (see next section).\n\nIn practical terms, the `failed` and `manual` strategies behave the same.\n\n\n## How to log custom messages\n\nThe log levels are :\n`PASSED`, `FAILED`, `INFO`, `WARNING` `ERROR` and `DEBUG`\n\n* To log a custom message without screenshot:\n\n  `Report4s.logMessage(Level.*, description);`\n\n* To log a custom message with a page screenshot :\n\n  `Report4s.logMessage(Level.*, description, webdriver);`\n\n* To log custom message with a WebElement screenshot :\n\n  `Report4s.logMessage(Level.*, description, webdriver, webelement);`\n\n* For WebElement screenshots an extra padding can be added :\n\n  `Report4s.logMessage(Level.*, description, webdriver, webelement, padding);`\n\nReplace `*` by `PASSED`, `FAILED`, `INFO`, `WARNING` `ERROR` and `DEBUG`\n\n\n## Sample Java code\n\nThe Report4s is able to log screenshots automatically upon webdriver events.\n\nScreenshots can alos be logged manually by making explicit calls to `Report4s.LogMessage` methods.\n\n```\n@Test(description = \"My test description\")\npublic void test1() {\n\n    this.driver.get(\"http://www.example.com\");\n    Report4s.logMessage(Level.PASSED, \"Manual log with screenshot\", this.driver);\n\n    WebElement elem;\n    elem = this.driver.findElement(By.name(\"xxxx\"));\n    elem.sendKeys(\"Hello World !!\");\n\n    elem = this.driver.findElement(By.id(\"xxxx\"));\n    elem.click();\n\n    Select sel = new Select(this.driver.findElement(By.name(\"xxxx\")));\n    sel.selectByValue(\"xxxx\");\n    Report4s.logMessage(Level.INFO, \"Manual log without screenshot\");\n\n    this.driver.navigate().back();\n}\n```\n\nYou are encouraged to use the `description` attribute of the `@Test` annotation to verbose your reports.\n\nA good tutorial on how to use testng with Selenium can be found here: http://testng.org/doc/selenium.html\n\nThe example is for Selenium v1 but the same principles also apply to Selenium v4.\n\n\n## Limitations\n\n* No support for any kind of parallel tests execution (multi-treads, multi-tabs or multi-windows).\n\n* No support for HtmlUnitDriver webdriver (Please use the standard webdrivers: Firefox, Chrome, Chromium, Edge or Safari).\n\n* Several ``FAILED`` messages are logged when using Waiting strategies (implicit, explicit or fluent wait)\n\n\n## Good Practices\n\nUse the `description` attribute of the `@Test` annotation to verbose your reports.\n\n` @Test(description = \"Sign in\")`\n\n***\n\nOne annoying thing of unit test frameworks, is that tests are executed in random order.\nSet the order of execution of methods directly in the testng XML files with the ``preserve-order`` attribute set to ``true``.\n\n```\n\u003csuite name=\"My test suite\"\u003e\n    \u003ctest name=\"My Test\" preserve-order=\"true\"\u003e\n        \u003cclasses\u003e\n            \u003cclass name=\"mypackage.MyTest\"/\u003e\n                \u003cmethods\u003e\n                    \u003cinclude name=\"method1\"/\u003e\n                    \u003cinclude name=\"method2\"/\u003e\n                    \u003cinclude name=\"method3\"/\u003e\n                \u003c/methods\u003e\n            \u003c/class\u003e\n        \u003c/classes\u003e\n    \u003c/test\u003e\n\u003c/suite\u003e\n```\nIn addition to that, you may also want to set the ``report4s.execution.skipSuiteAfterTestFailure`` property to ``true``.\n\nBy doing so, if for example ``method1`` fails, then ``method2`` and ``method3`` will be skipped.\n\nBy default, ``report4s.execution.skipSuiteAfterTestFailure`` is set to ``false``.\n\n***\n\nTo avoid several `FAILED` logs when using Waiting strategies,\ndeactivate the automatic screenshot gathering before the wait,\nthen reactivate it after the wait.\n\n```\n    // Deactivate automatic screenshots\n    Report4s.screenshots = null;\n\n    WebDriverWait wait = new WebDriverWait(this.driver, Duration.ofSeconds(10));\n    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(\"my-id\")));\n    this.driver.findElement(By.id(\"my-id\")).click();\n\n    // Reactivate automatic screenshots\n    Report4s.screenshots = \"all\";    // or \"last\", \"failed\".\n```\n\n\n## report4s.properties file\n\n```\n#IF YOU WANT TO MODIFY A PROPERTY DEFAULT VALUE,\n#UNCOMMENT THE APPROPRIATE LINE AND SET THE VALUE OF YOUR CHOICE.\n\n\n#The report directory relative to the workspace (working directory).\n#It is advisable to avoid using the same TestNG default report directory (test-output).\n#report4s.report.dir=report\n\n\n#The file name of the report homepage.\n#report4s.report.homepage=index.html\n\n\n#The title of the report home page.\n#report4s.report.title=Test Execution Summary\n\n\n#Path of custom CSS file to add to the report.\n#report4s.report.css=\n\n\n#The screenshot gathering strategy.\n#Values: all, last, failed or manual.\n#report4s.screenshots.enabled=all\n\n\n#Whether to take screenshots of WebElements or pages.\n#Values: page or element.\n#report4s.screenshots.target=page\n\n\n#Padding in pixels to be applied to WebElement screenshots.\n#Defines the area around the WebElement to be included in the screenshot.\n#report4s.screenshots.padding=10\n\n\n#Whether to gather web page sources.\n#report4s.pagesources.enabled=false\n\n\n#The number of decimals of precision to be displayed in execution time labels.\n#The value should be an integer between 0 and 3.\n#report4s.time.precision=0\n\n\n#Whether to display tooltips with the execution result for each individual suite.\n#report4s.suite.tooltips.enabled=true\n\n\n#Whether to skip the remaining tests of the current suite if a test fails.\n#report4s.execution.skipSuiteAfterTestFailure=false\n```\n\n\n## Sample screenshots\n\n![](docs/image-1.png)\n\n![](docs/image-2.png)\n\n![](docs/image-3.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmin-parra%2Freport4s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharmin-parra%2Freport4s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmin-parra%2Freport4s/lists"}