Codacy Badge

Gradle

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation group: 'com.github.visual-regression-tracker', name: 'sdk-java', version: '${REPLACE_THIS_VALUE}'
}

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.github.Visual-Regression-Tracker</groupId>
    <artifactId>sdk-java</artifactId>
    <version>${REPLACE_THIS_VALUE}</version>
</dependency>

Available versions

More info about https://jitpack.io/

Usage

  • Create config
VisualRegressionTrackerConfig config = new VisualRegressionTrackerConfig(
    // apiUrl - URL where backend is running 
    "http://localhost:4200",
    
    // project - Project name or ID
    "003f5fcf-6c5f-4f1f-a99f-82a697711382",
    
    // apiKey - User apiKey
    "F5Z2H0H2SNMXZVHX0EA4YQM1MGDD",
    
    // branch - Current git branch 
    "develop",
    
    // enableSoftAssert - Log errors instead of exceptions
    false,
 
    // ciBuildId - id of the build in CI system
    "CI_BUILD_ID",
    
    // httpTimeoutInSeconds - define http socket timeout in seconds (default 10s)
    15

);
  • Create an instance of VisualRegressionTracker
VisualRegressionTracker visualRegressionTracker = new VisualRegressionTracker(config);
  • Take a screenshot as String in Base64 format
// Selenium example
String screenshotBase64 = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
  • Track image

Default options

visualRegressionTracker.track(
        "Name for test",
        screenshotBase64
);

With specific options

visualRegressionTracker.track(
        "Name for test",
        screenshotBase64,
        TestRunOptions.builder()
            .browser("Chrome")
            .os("Windows")
            .viewport("1200x800")
            .diffTollerancePercent(3.0f)
            .build()
);