Integrate Visual E2E Testing Into Your CI
Get continuous visual test automation by integrating Visual E2E tests directly into your continuous integration (CI) build.
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.
- JavaScript
- Java
- Python
- Ruby
- C#
WebDriverIO Example:
const result = driver.execute('/*@visual.end*/')
assert.ok(result.passed, result.message)
Map response = (Map)js.executeScript("/*@screener.end*/");
Assert.assertTrue((Boolean)response.get("passed"), (String)response.get("message"));
result = self.driver.execute_script('/*@visual.end*/')
assert result['passed'] is True
result = driver.execute_script '/*@visual.end*/'
expect(result.passed).to eq(true)
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
- CircleCI
- TravisCI
- GitLab
- Codeship
- Buildkite
- Drone
capabilities: {
...
'sauce:options': {
build: process.env.BUILD_NUMBER
}
}
capabilities: {
...
'sauce:options': {
build: process.env.CIRCLE_BUILD_NUM
}
}
capabilities: {
...
'sauce:options': {
build: process.env.TRAVIS_BUILD_NUMBER
}
}
capabilities: {
...
'sauce:options': {
build: process.env.CI_PIPELINE_ID
}
}
capabilities: {
...
'sauce:options': {
build: process.env.CI_BUILD_NUMBER
}
}
capabilities: {
...
'sauce:options': {
build: process.env.BUILDKITE_BUILD_NUMBER
}
}
capabilities: {
...
'sauce:options': {
build: process.env.DRONE_BUILD_NUMBER
}
}
Next Steps
- Invite users to your project.
- Troubleshooting.