Search by

delta-qa / vision

TheMalloum

Delta-QA Vision SDK: a php-webdriver test sends its pages to Delta-QA and reads the verdict

v0.0.1-beta2 2026-11-29 17:18 UTC

This package is auto-updated.

Last update: 2026-11-29 18:34:05 UTC


README

Delta-QA's visual regression SDK for php-webdriver. A test sends its pages to Delta-QA, which compares each of them with the reference of the test in the same environment. Delta-QA is artificial sight: it compares the way a human eye would. A pixel-by-pixel comparison flags differences no one can see — false positives — and misses changes a person notices — false negatives. Delta-QA reports only the differences a person can see, and decides the result.

Requirements

  • PHP 8.1 or later, with the curl and json extensions
  • php-webdriver/webdriver 1.15 or later. Laravel Dusk, Symfony Panther and Codeception run on it: give the SDK the RemoteWebDriver they expose.

Installation

composer require --dev delta-qa/vision

Environment variables

Variable Purpose
DELTAQA_API_KEY An API key of your workspace (dqa_…) whose role can edit, to send pages. An administrator creates it in Settings → Workspace → API keys; it is shown once. The workspace is the key's: there is no workspace setting
DELTAQA_SERVER_URL The root of your Delta-QA server, e.g. http://localhost:9327; the SaaS, https://api.delta-qa.com, when not set

Without a key, opening a test fails and names the variable to set. The key is sent in the Authorization header only: it never appears in an error message, a log or a link of the SDK.

The Vision API

use DeltaQa\Vision\CheckSettings;
use DeltaQa\Vision\Vision;
use DeltaQa\Vision\VisionSettings;
use Facebook\WebDriver\WebDriverBy;

$vision = Vision::open($driver, new VisionSettings(
    id: 'checkout',
    name: 'Checkout',
    commit: getenv('GITHUB_SHA'),
    branch: getenv('GITHUB_HEAD_REF') ?: null,
    baseBranch: getenv('GITHUB_BASE_REF') ?: null,
));
$driver->get('https://shop.example/cart');
$vision->check('Cart');
$driver->findElement(WebDriverBy::id('pay'))->click();
$vision->check('Payment', new CheckSettings(ignore: ['#now', WebDriverBy::id('advert')]));
$results = $vision->close(); // throws VisionTestFailedException when Delta-QA decides UNRESOLVED, REJECTED or FAILED

Call close() at the end of the test, not in a finally or a tearDown: it waits for the verdict, and a failure there would hide the test's own error. A test that already failed leaves its launches open; Delta-QA closes them after a delay.

VisionSettings takes these named arguments; sizes is a list of new Size(width, height):

Setting Meaning
id What recognises the test, with app: keep it when the name changes; a new id is a new test
name The name Delta-QA shows the test under
commit Required: the git commit tested, its hash as the CI gives it
tag The git tag of the commit, shown beside it; null when the commit has none — the common case
branch The branch of the launch; null when the run is on no branch (the build of a tag, a detached commit)
baseBranch The branch whose reference is used while the branch has none — the target of a pull or merge request; null without one. Equal to the branch, it is not sent
app The application of the test, a label; optional
sizes The sizes the page is taken at: one launch per size, the page resized in the test's browser at each check and given back its size, its resources sent once; without it, the page's own size
saveNewTests Whether the pages of a new test become its reference (result NEW); true when absent, false to judge them first (UNRESOLVED)

A setting given as an empty text is refused when the test opens, and nothing is sent.

Demo

The GoodDeal practice tests hold ready-to-run tests against GoodDeal, a free demo store: four journeys (an order, a declined card, the contact form, the sign-in), each with a Vision check at every step. The Vision tests run when DELTAQA_API_KEY is set.

Framework Demo
php-webdriver php/selenium

The commit, the tag and the branches

The SDK reads neither git nor your CI: give it the values of the run, read in the variables of your CI. commit is required; the others are absent (null) when they do not exist.

CI commit tag branch base branch
GitHub Actions GITHUB_SHA GITHUB_REF_NAME when GITHUB_REF_TYPE is tag GITHUB_HEAD_REF, else GITHUB_REF_NAME when GITHUB_REF_TYPE is branch GITHUB_BASE_REF
GitLab CI CI_COMMIT_SHA CI_COMMIT_TAG CI_MERGE_REQUEST_SOURCE_BRANCH_NAME, else CI_COMMIT_BRANCH CI_MERGE_REQUEST_TARGET_BRANCH_NAME
Bitbucket Pipelines BITBUCKET_COMMIT BITBUCKET_TAG BITBUCKET_BRANCH BITBUCKET_PR_DESTINATION_BRANCH
Azure Pipelines BUILD_SOURCEVERSION BUILD_SOURCEBRANCH of the form refs/tags/… SYSTEM_PULLREQUEST_SOURCEBRANCH, without its refs/heads/, else BUILD_SOURCEBRANCH of the form refs/heads/… SYSTEM_PULLREQUEST_TARGETBRANCH, without its refs/heads/

Machines that run the same suite in parallel share one commit by giving the same text.

Browsers

The page is taken in Chrome, Chromium or Edge, through the browser's DevTools protocol, at a device pixel ratio of 1. Under another browser (Firefox, Safari), opening a test fails with an unsupported-browser error, and nothing is sent.

A check is taken from the top document of the page: switch back out of any frame before checking.

Checks and zones

check(name) sends the page as the test sees it now — the live DOM, the state of its fields, its web components and its frames, and the files it uses. Every check of a test has its own name: a name already taken is refused, and nothing is sent.

A check can leave zones out of the comparison (ignore: a clock, an advert) or compare one zone alone (region). A zone is a CSS selector (a string), a WebDriverBy or a WebDriverElement. Every element a zone designates is one zone; a zone that designates none fails the check, and nothing is sent.

$vision->check('Cart', new CheckSettings(ignore: ['#now'], region: 'main'));

The verdict

close() closes every launch of the test and waits for Delta-QA's result (at most 15 minutes):

Result The test
NEW Passes: the pages became the reference of a new test
PASSED Passes: the same pages as the reference
UNRESOLVED Fails: a difference waits for a person's judgment — the message gives the link of the commit in Delta-QA
REJECTED Fails: a difference was judged a bug
FAILED Fails: Delta-QA could not compare the pages

A second call to close() gives the same results, or the same failure, without asking Delta-QA again.

Errors

Error When
DeltaQaConfigurationException A variable is missing or wrong; the error names it
DeltaQaApiException Delta-QA refused a request: its code names the cause (e.g. API_KEY_INVALID, INSUFFICIENT_ROLE, LAUNCH_CLOSED), its ticket names the occurrence — quote it to the support
DeltaQaUnreachableException No answer came from the server; the cause says what the network said
UnsupportedBrowserException The browser is not Chrome, Chromium or Edge; nothing is opened
UnsupportedDensityException The page is shown at a device pixel ratio other than 1
DuplicateCheckNameException check was given a name already taken in the test; nothing is sent
ZoneNotFoundException A zone of check matches no element of the page; the error names it, and nothing is sent
ResourceUnreadableException A file the page cites could not be read, or did not come whole within 30 seconds; the error names its address
ResourceTooLargeException A file the page cites is larger than Delta-QA admits; the check is not sent
LaunchResultTimeoutException The wait for a result ran out; the launch keeps running on Delta-QA, and the message gives the address of its comparison
VisionTestFailedException Delta-QA decided a launch UNRESOLVED, REJECTED or FAILED: the results give each launch, its comparison, and the link of the commit

Every class lives in the namespace DeltaQa\Vision.

Your data

What the SDK sends — the pages your tests check and the files they use — serves only to compare them. Testing on production personal data is your responsibility: run your suites on test data.

To read a file the page cites and the browser cannot hand over, the SDK asks for it itself, as the browser would: with the browser's cookies for that address, its user agent and its Referer. Only http and https addresses are read.

Versions

The SDK is released with Delta-QA: its version is the Delta-QA release that published it. Its compatibility is carried by the API it calls — the Vision API v1, /api/vision/v1, a frozen contract that only grows. A breaking change of the API is a v2, deployed beside v1, and v1 keeps answering until its announced end.

Licence

Apache License 2.0 — see LICENSE and NOTICE. Calling Delta-QA requires a Delta-QA API key.

Support: support@delta-qa.com · https://delta-qa.com