Skip to main content
Visual Testing · Stack

Visual Testing for Angular with WebdriverIO

Visual testing for Angular with WebdriverIO adds screenshot comparisons to the WebdriverIO specs many Angular teams adopted after Protractor was deprecated. The @wopee-io/wopee.wdio service adds commands such as browser.trackScreen() and browser.trackFullPageScreen(), sends each screenshot to Wopee.io, and compares it with the approved baseline for your branch, so you review layout and styling changes in Wopee Commander instead of in local image folders.

Why visual testing Angular with WebdriverIO is hard

Many Angular teams moved their end-to-end suites from Protractor to WebdriverIO, kept the page objects, and now want visual coverage on top. The obvious option, WebdriverIO's own visual service, compares against baseline images stored on disk, which means deciding where those folders live, keeping them in sync between developers and CI, and reviewing differences as files. Angular adds its own timing problems: views finish rendering after change detection, Material components animate, and web fonts swap in after the first paint, so screenshots taken right after a click are unstable. Desktop screenshots also need care, because a setting meant for mobile devices can crop the image, and dialogs rendered in the CDK overlay container are not part of the component an element screenshot targets.

How Wopee.io adds visual checks to WebdriverIO

The Wopee.io service plugs into wdio.conf.ts like any other WebdriverIO service. Connection settings go inside screenshotValidation (API key and project UUID, plus branchName and baselineBranchName from your CI), and isLandscape: false sits next to it for desktop browsers, because the default is meant for mobile devices in landscape. In a spec, browser.startSuite and browser.startScenario group the screenshots; browser.trackScreen captures the visible part of the page, browser.trackFullPageScreen scrolls and stitches the whole page, and browser.trackElement captures one element, which in WebdriverIO 9 takes await $(selector).getElement(). Wait for the Angular view and its fonts before each call, for example with waitForDisplayed and a browser.execute that awaits document.fonts.ready. imageProcessing can mask or crop fixed screen edges on every screenshot, and pixelToPixelDiffTolerance absorbs tiny rendering noise. Baselines and the review live in Wopee Commander per branch; each track command returns a status you can assert on if a difference should fail the run. For broader coverage, see AI testing for Angular and the WebdriverIO guide.

How to get started

  1. 1
    Create a Wopee.io project with the test framework set to WebdriverIO and copy WOPEE_PROJECT_UUID and a new WOPEE_API_KEY into a .env file.
  2. 2
    Install with npm install --save-dev @wopee-io/wopee.wdio dotenv and add the service to wdio.conf.ts with screenshotValidation settings and isLandscape: false.
  3. 3
    Add @wopee-io/wopee.wdio to the types in tsconfig.json so browser.trackScreen and the other commands are typed.
  4. 4
    In each spec, start the suite once in before, start a scenario per test, and call a track command after the Angular view and its fonts have settled.
  5. 5
    Run npx wdio run wdio.conf.ts, approve the first screenshots in Commander, and review unresolved steps on later runs.

Example: a WebdriverIO test with visual checks

test/specs/dashboard.visual.ts
import { browser, $ } from '@wdio/globals';

describe('Angular dashboard', () => {
before(async () => {
await browser.startSuite(`Angular WDIO ${new Date().toISOString().slice(0, 16)}`);
});

it('shows the dashboard and the filter menu', async () => {
await browser.startScenario('Dashboard: overview and filter menu');

await browser.url('http://localhost:4200/dashboard');
await $('h1=Dashboard').waitForDisplayed();
await browser.execute(async () => {
await document.fonts.ready;
});
const overview = await browser.trackFullPageScreen({ stepName: 'Dashboard' });
console.log('Dashboard:', overview.screenshotValidationResult?.status);

await $('button[aria-label="Filter"]').click();
await $('.cdk-overlay-pane').waitForDisplayed();
await browser.trackScreen({ stepName: 'Filter menu open' });

await browser.stopScenario();
});
});

From manual effort to AI-assisted testing

More automation. Less maintenance. Faster review.

Manual check before release

Where baselines live
In the tester's memory
Desktop and mobile
Devices at hand
Review of differences
By eye
Branches in CI
None

WebdriverIO visual service

Where baselines live
Image folders on disk
Desktop and mobile
Configured per capability
Review of differences
Diff images as files
Branches in CI
Handled with your own folder strategy
Wopee.ioWopee.io
AI testing
Where baselines live
Wopee.io, per branch and labels
Desktop and mobile
isLandscape: false for desktop
Review of differences
Approve or reject per step in Commander
Branches in CI
branchName and baselineBranchName in config

Add visual checks to your WebdriverIO tests

Keep your tests, add a few track calls, and review every visual change in one place.

Frequently asked questions

No. Pass every value through screenshotValidation in wdio.conf.ts, for example apiKey: process.env.WOPEE_API_KEY, after loading .env with dotenv.

The isLandscape option defaults to true, which is meant for mobile devices in landscape orientation. Set isLandscape: false next to screenshotValidation for desktop browsers.

Yes, if you want it to. Each track command returns screenshotValidationResult with a status; assert that it is not unresolved. By default the test passes and the step waits for review in Wopee Commander.