Integrate into CI

Get continuous visual test automation by integrating into your Continuous Integration (CI) process.

If your tests are already integrated into CI, get visual results returned into your tests and pass or fail your builds depending on visual regressions found.


1

Return Visual results into your WebDriver test(s)

To get the test results, add the "@visual.end" command right before ending your test session. The returned result can then be asserted to pass or fail your test.



WebDriverIO Example:
const result = driver.execute('/*@visual.end*/');
assert.ok(result.passed, result.message);
Java Example:
Map response = (Map)js.executeScript("/*@screener.end*/");
Assert.assertTrue((Boolean)response.get("passed"), (String)response.get("message"));
Python Example:
result = self.driver.execute_script('/*@visual.end*/')
assert result['passed'] is True
Ruby Example:
result = driver.execute_script '/*@visual.end*/'
expect(result.passed).to eq(true)
C# Example:
dynamic result = js.ExecuteScript("/*@visual.end*/");
Assert.IsTrue(result.passed, result.message);

For more details on results returned, view the Visual Commands documentation.


2

Integrate your CI Build

Associate your Visual tests with your CI build number by setting the build option in your capabilities.

Below are build number environment variables for various CI tools:



Jenkins Example:
capabilities: {
  ...
  'sauce:options': {
    build: process.env.BUILD_NUMBER
  }
}
CircleCI Example:
capabilities: {
  ...
  'sauce:options': {
    build: process.env.CIRCLE_BUILD_NUM
  }
}
Travis CI Example:
capabilities: {
  ...
  'sauce:options': {
    build: process.env.TRAVIS_BUILD_NUMBER
  }
}
GitLab Example:
capabilities: {
  ...
  'sauce:options': {
    build: process.env.CI_PIPELINE_ID
  }
}
Codeship Example:
capabilities: {
  ...
  'sauce:options': {
    build: process.env.CI_BUILD_NUMBER
  }
}
Buildkite Example:
capabilities: {
  ...
  'sauce:options': {
    build: process.env.BUILDKITE_BUILD_NUMBER
  }
}
Drone Example:
capabilities: {
  ...
  'sauce:options': {
    build: process.env.DRONE_BUILD_NUMBER
  }
}

Next Steps