Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
harmin-parra committed May 17, 2021
0 parents commit 4101d69
Show file tree
Hide file tree
Showing 103 changed files with 22,299 additions and 0 deletions.
75 changes: 75 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
v4.0
====
* The test report has been simplified. It's now displayed in a table of 3 columns instead of 6.
* Implementation of a WebDriver Event Listener,
which makes the logging process more simple an less intrusive.
* Whenever possible, a screenshot is taken right after a test failure.
* Homogeneity between test and configuration execution reports.
* Stop the creation of html report files if the extraction of resources from the jar file fails.


v3.1
====
* Possibility to display a test result piechart for each individual suite.


v3.0
====
* Possibility to export the test results in Excel .xlsx format.
* Possibility to only take screenshots for steps logged as FAILED.
* The "Test failures but within success percentage" label will not be
printed in the piechart legend if such tests were not logged.


v2.2
====
* Possibility to skip the remaining steps of the current test execution
if a step is logged with the FAILED level.
* Possibility to skip the remaining tests of the current suite if a test fails.
* "Test failures but within success percentage" are logged.
* Resolution of a bug that kept taking screenshots if the listeners
weren't added in the testng xml file.
* Possibility to log messages in configuration methods.
* Resolution of a bug that causes Report4s to crash in the presence of multi-threaded tests.


v2.1
====
* Test names are no longer logged.
Instead of that, report4s will log the description attribute of the @test annotations.
* Configuration failures/skips are logged.
* Possibility to configure the aggregation to be displayed in the pie chat.
* Possibility to display tooltips with the execution result for each individual suite.
* Resolution of a bug when printing INFO, WARNING and DEBUG logs when screenshots are disabled.
* All file-writing related code has been moved into a single java class.


v2.0
====
* An overview of the test methods execution for each suite is available in the index page of the report.
in the report homepage be means of expand/collapse buttons.
* The HTML presentation code has been completely moved into a CSS file.
* A suite is logged as skipped if all its tests are skipped due to a configuration failure.


v1.3
====
* Addition of the TRACE log level.
* Exceptions are printed inside the html table report as a TRACE level log.
* Addition of a button that allows to expand/collapse an exception stack trace.


v1.2
====
* If screenshots are disabled, the html table column allocated
for screenshots is not printed in the test log reports.
* Users have the possibility to change the following properties within java code :
- report4s.screenshots.enabled
- report4s.screenshots.padding
- report4s.time.precision
This allows, for example, to disable/enable screenshots for a given suite test execution.


v1.1
====
* Improvements in the validation of integer property values that are read from the report4s.properties file.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Harmin Parra Rueda

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
270 changes: 270 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
Thank you for using Report4s.
Report4s is a Selenium HTML reporter for the TestNG framework.
It is compatible with both Selenium 2 and Selenium 3.

Report4s is able to log the following web browser events :

* Select.deselectByIndex(int)
* Select.deselectByValue(java.lang.String)
* Select.deselectByVisibleText(java.lang.String)
* Select.selectByIndex(int)
* Select.selectByValue(java.lang.String)
* Select.selectByVisibleText(java.lang.String)

* WebDriver.get(java.lang.String)
* WebDriver.navigate().back()
* WebDriver.navigate().forward()
* WebDriver.navigate().refresh()
* WebDriver.navigate().to(java.lang.String)
* WebDriver.navigate().to(java.net.URL)

* WebElement.click()
* WebElement.sendKeys(CharSequence[])

You have also the possibility to log custom messages with either a full web page or a web element screenshot.


**********************************************************************
* The zip file contents *
**********************************************************************

report4.zip
|---javadoc The API documentation
|---report4s.properties Configuration file (optional)
|---lib
|---report4s.jar The report4s library
|---commons-io-2.5.jar --|
|---poi-3.14.jar | Required
|---poi-ooxml-3.14.jar |-- external
|---poi-ooxml-schemas-3.14.jar | libraries
|---xmlbeans-2.6.0.jar --|
|---guava-22.0.jar Required for selenium 2


**********************************************************************
* Requirements *
**********************************************************************

- Java 7 or later
- testng 6.9.4 or later


**********************************************************************
* Caution *
**********************************************************************

DO NOT RENAME THE report4s JAR FILE.

**********************************************************************
* Installation *
**********************************************************************

- Add the jar files to the classpath.
- Add report4s.properties file to your project root folder (optional).


**********************************************************************
* TestNG XML files configuration *
**********************************************************************

Add the following lines before the closing </suite> tag
in each TestNG XML file :

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="..." >
...
...
<listeners>
<listener class-name="net.sourceforge.report4s.ReportIndex" />
<listener class-name="net.sourceforge.report4s.SuiteListener" />
<listener class-name="net.sourceforge.report4s.TestListener" />
<!-- The configuration listener is optional -->
<listener class-name="net.sourceforge.report4s.ConfigurationListener" />
</listeners>
</suite>


**********************************************************************
* The packages to import *
**********************************************************************

import net.sourceforge.report4s.*;

or

import net.sourceforge.report4s.EventHandler;
import net.sourceforge.report4s.Report4s;
import net.sourceforge.report4s.Level;


**********************************************************************
* The test configuration *
**********************************************************************

We need to wrap the WebDriver into an Event Listener

public class MyTest {

private static WebDriver driver;
private static EventFiringWebDriver eventDriver;

@BeforeSuite(alwaysRun=true)
public void setUp() {
. . . .
. . . .
eventDriver = new EventFiringWebDriver(driver);
EventHandler handler = new EventHandler();
eventDriver.register(handler);
eventDriver.manage().window().maximize();
}
}


**********************************************************************
* How to log *
**********************************************************************

The log levels are :

PASSED, FAILED, INFO, WARNING, DEBUG, ERROR and TRACE

----------------------------------------------------------------------

To log a web browser event

Report4s.logEvent(String description, boolean screenshot);

----------------------------------------------------------------------

To log a custom message :

Report4s.logMessage(Level.*, description);

----------------------------------------------------------------------

To log a custom message with a full page screenshot :

Report4s.logMessage(Level.*, description, webdriver);

----------------------------------------------------------------------

To log custom message with a WebElement screenshot :

Report4s.logMessage(Level.*, description, webdriver, webelement);

----------------------------------------------------------------------

For WebElement screenshots you have the possibility to apply an extra padding

Report4s.logMessage(Level.*, description, webdriver, webelement, padding);


replace * by INFO, WARNING or DEBUG
No screenshot will be taken if the driver is an instance of HtmlUnitDriver.


**********************************************************************
* Sample Java code *
**********************************************************************

The Report4s.logEvent method should be called right before
the call of the event you want to log.

@Test(description = "My test description")
public void test1() {

Report4s.logEvent("Open web site", true);
eventDriver.get("http://www.example.com");

WebElement elem;
elem = eventDriver.findElement(By.name("xxxx"));
Report4s.logEvent("send keys", true);
elem.sendKeys("Hello World !!");

elem = eventDriver.findElement(By.id("xxxx"));
Report4s.logEvent("click on button", true);
elem.click();

Select sel = new Select(eventDriver.findElement(By.name("xxxx")));
Report4s.logEvent("click on select", true);
sel.selectByValue("xxxx");

Report4s.logEvent("Navigate back", true);
eventDriver.navigate().back();
}


**********************************************************************
* report4s.properties file *
**********************************************************************

#IF YOU WANT TO MODIFY A PROPERTY DEFAULT VALUE,
#UNCOMMENT THE APPROPRIATE LINE AND SET THE VALUE OF YOUR CHOICE.


#The report directory relative to the workspace (working directory)
#It is advisable to avoid using the same TestNG default report directory (test-output)
#report4s.report.dir=report


#The file name of the report homepage.
#report4s.report.homepage=index.html


#The title of the report home page.
#report4s.report.title=Test Execution Summary


#The excel report filename.
#report4s.report.excel=Test report.xlsx


#Whether to enable screenshots.
#Regardless its value, a screenshot is taken right after a test failure whenever possible.
#report4s.screenshots.enabled=true


#Padding in pixels to be applied to WebElement screenshots.
#Defines the area around the WebElement to be included in the screenshot.
#report4s.screenshots.padding=0


#The number of decimals of precision to be displayed in execution time labels.
#The value should be an integer between 0 and 3.
#report4s.time.precision=0


#The pie chart aggregation to be plotted.
#Possible values: suite, test or both.
#report4s.piechart.aggregation=suite


#Whether to display tooltips with the execution result for each individual suite.
#report4s.suite.tooltips.enabled=true


#Whether to display a test result piechart or a status icon for each individual suite.
#Possible values: piechart or icon. (The icons are: PASSED, FAILED or SKIPPED)
#report4s.suite.status.content=icon


#The width and height values in pixels for the piecharts in the status column.
#This property will be ignored if report4s.suite.status.content is set to "icon".
#report4s.suite.status.size=35px


#Whether to skip the remaining steps of the current test execution
#if a step is logged with the FAILED level.
#report4s.execution.skipTestAfterStepFailure=false


#Whether to skip the remaining tests of the current suite if a test fails.
#report4s.execution.skipSuiteAfterTestFailure=false


**********************************************************************
* Limitations *
**********************************************************************

No support for multi-threaded tests.

3 changes: 3 additions & 0 deletions browser.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
browser=firefox
#browser=chrome
#browser=ie
Loading

0 comments on commit 4101d69

Please sign in to comment.