Skip to Content

Usage

Usage Modes

Level CI WebdriverIO supports two modes: manual and background.


Manual Mode

Manual mode is done using the levelAnalyze() function. It analyzes the page currently open in your Browser object.

Use case: you open a page, call levelAnalyze(), then interact with the page (changing layout or adding/removing elements). To capture the final state, you must call levelAnalyze() again.

Basic Usage

describe('testing my page', () => { it('should pass levelAnalyze', async () => { await browser.url('http://localhost:5000') await levelAnalyze(browser, { screenshots: false, }) }) })

Notes:

  • The first argument is your WebdriverIO.Browser object.
  • The second argument is a configuration object that can override the global configuration set via setupLevel().
  • levelAnalyze() generates reports, optionally screenshots, and returns analysis data including violations, full report, and screenshot metadata.

Drawback:

  • You need to call it each time the page changes or when switching pages, which may lead to many calls.

Background Mode

Background mode runs analysis in the background using LevelController.

  1. Create the controller (e.g., in beforeAll) with your Browser object and config.
  2. Call start() to enable the background runner.
describe('background runner example', () => { let levelController before(async () => { levelController = new LevelController(browser, { elementScreenshots: true, printViolationsTable: true, ignoreUrls: ['http://localhost:5000'], }) levelController.start() }) afterEach(async () => { await levelController.analyze() }) after(async () => { await levelController.stop() }) it('triggers background analysis', async () => { await browser.url('http://localhost:5000') await browser.setWindowSize(1000, 1000) }) it('triggers background analysis on interaction', async () => { const paragraph = $('#paragraph') await paragraph.click() }) })

Notes:

  • Calls to levelAnalyze() are automatically run in the background before WebdriverIO API methods.
  • analyze() can also be used manually; it behaves like levelAnalyze() using the browser and config provided to the controller.
  • You can stop the background runner with stop(). Restart it with start() anytime.

Using Both Modes

By default, both modes are available. You can restrict to one mode using the environment variable LEVEL_CI_WEBDRIVERIO_MODE:

  • "manual" → only manual mode runs
  • "background" → only background mode runs
  • Any other value → both modes are enabled (default: "all")
Last updated on