VisualRegressionFramework
Second version
Install / Use
/learn @a13xh7/VisualRegressionFrameworkREADME
Visual regression framework: Java + TestNG + Selenium Webdriver + Selenide + aShot
Installation
- Install java
- Install maven
- Install browsers (chrome, firefox)
Configuration
-
src/config/framework.properties- configuration filebreakpoints=1920,768,360- breakpointsallowableDiffSize=10- allowable number of different pixels between two screenshots
-
src/main/java/framework/Configclass - configuration logic
Default breakpoints
- Desktop: breakpoint >= 1024px
- Tablet: breakpoint >= 768px AND breakpoint < 1024px
- Mobile: breakpoint = < 768px
You can change breakpoints in Report.getBreakpointType() method.
Screenshots comparison
Pages
- Compare page screenshots - all breakpoints
Comparer.comparePages("test_name");
- Hide elements and compare page screenshots - all breakpoints
Comparer.comparePages("test_name", new String[]{"igrored_element_css_locator", "igrored_element"});
- Compare page screenshots with specified breakpoint
Comparer.comparePagesWithBreakpoint("test_name", "1920");
- Hide elements and compare page screenshots with specified breakpoint
Comparer.comparePagesWithBreakpoint("test_name", "1920", new String[]{"igrored_element"});
Elements
- Compare element screenshots - all breakpoints
Comparer.compareElements("test_name", "css_locator");
- Compare element screenshots with specified breakpoint
Comparer.compareElementsWithBreakpoint("test_name", "1920", "css_locator");
Tests architecture
A_BeforeAllTests- remove temporary screenshots, clear logs, init config before all testsA_AfterAllTests- generate report after all testsA_ErrorsLogListener- save errors for reportA_BaseTest- all test classes must extend this classtestng.xml- add new test classes into this file, betweenA_BeforeAllTestsandA_AfterAllTests
Test execution
You can run tests using next command:
mvn test -Dbrowser=chrome
parameters
-Dbrowser=chrome- browser. chrome or firefox.-Dheadless=1- 0 or 1. run browser in headless mode-Dclean=1- 0 or 1. remove expected screenshots and save actual ones as expected screenshots
All parameters are optional. Default values are set in Config class.
Report
Report is generated in A_AfterAllTests class.
Report is located in report folder.
