expect-webdriverio
WebdriverIO Assertion Library
Last updated 20 days ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install expect-webdriverio 
SYNC missed versions from official npm registry.

expect-webdriverio Test

[!IMPORTANT] This branch is v8 (WebdriverIO v10), not released yet.

expect-webdriverio WebdriverIO Node.js Status Docs
v8 v10 ≥ 22.23.4, 24.22.1 or 26.12.1 In development This README
v7 v9 (≥ 9.31.5) ≥ 20 Latest release, fixes only v7 README
API | Multiple Elements | Multi-remote | Frameworks | TypeScript / JS Autocomplete | Examples | Extending Matchers | Migration from v7

WebdriverIO assertion library inspired by expect

Key Features

  • Waits for expectations to succeed
  • Supports single element $() & multiple elements $$()
  • Supports multi-remote browsers & elements, with one expected value per browser instance
  • Detailed error messages
  • Works in Mocha, Cucumber, Jest, and Jasmine
  • Built-in types for TypeScript and JS autocompletion

Installation

  1. npm install expect-webdriverio
  2. Install your test framework adapter (if not already set up via WDIO testrunner):
    • Mocha (default): npm install @wdio/mocha-framework
    • Jasmine: npm install @wdio/jasmine-framework
    • Cucumber: npm install @wdio/cucumber-framework
    • Jest: No adapter needed — see Jest Framework section

Note: WebdriverIO v10.0.0 or higher is required!

Usage

Using WebdriverIO Testrunner

If you run your tests through the WDIO testrunner, no additional setup is needed. WebdriverIO initializes expect-webdriverio and makes expect available in the global scope so you can use it directly in your tests:

await expect($('#submit')).toBeDisplayed()
await expect($$('buttons')).toBeDisplayed()

See more Examples.

Multi-remote

With multi-remote, assertions check every browser instance, with a single expected value or one per instance:

await expect(multiRemoteBrowser).toHaveTitle('WebdriverIO')
await expect(multiRemoteBrowser.$('h1')).toHaveText(expect.multiRemote({ chrome: 'Welcome', firefox: 'Bienvenue' }))

Local & Browser Runners

  • Local Runner: Fully compatible. You can leverage your test framework adapter as mentioned above.
  • Browser Runner: Designed for component frameworks like React, Preact, Vue.js, Svelte, and SolidJS, with a few known limitations. For details, see the Browser Runner Framework section.

Using in Standalone Mode

If you use WebdriverIO in standalone mode (without @wdio/globals), make sure you import expect-webdriverio before using it anywhere.

import { remote } from 'webdriverio'
import { expect } from 'expect-webdriverio'

;(async () => {
    const browser = await remote({
        capabilities: {
            browserName: 'chrome'
        }
    })

    await browser.url('https://webdriver.io')

    const $button = await browser.$('.DocSearch-Button')
    await expect($button).toBeDisplayed()
    
    await browser.deleteSession()
})().catch(console.error)

API

Please see the API documentation.

Error Messages

Error messages are informative out of the box and contain:

  • Full element selector, like $('form')
  • Actual and expected values
  • Highlighted differences (text assertions)

toHaveText toHaveElementClass

What's Next?

First of all, feel free to raise an issue with your suggestions or help with PRs!

Current Tags

  • 8.1.0                                ...           latest (20 days ago)
  • 4.15.4                                ...           legacy-v4 (2 years ago)
  • 8.0.0-alpha.3                                ...           next (2 months ago)

159 Versions

  • 8.1.0                                ...           20 days ago
  • 8.0.0                                ...           2 months ago
  • 8.0.0-alpha.3                                ...           2 months ago
  • 8.0.0-alpha.2                                ...           2 months ago
  • 7.0.1                                ...           2 months ago
  • 8.0.0-alpha.1                                ...           2 months ago
  • 5.3.2                                ...           a year ago
  • 8.0.0-alpha.0                                ...           2 months ago
  • 7.0.0                                ...           2 months ago
  • 6.1.0                                ...           2 months ago
  • 6.1.0-alpha.0                                ...           2 months ago
  • 6.0.10                                ...           3 months ago
  • 6.0.9                                ...           3 months ago
  • 6.0.8                                ...           3 months ago
  • 6.0.7                                ...           3 months ago
  • 6.0.6                                ...           3 months ago
  • 6.0.5                                ...           3 months ago
  • 6.0.4                                ...           3 months ago
  • 6.0.3                                ...           3 months ago
  • 6.0.2                                ...           4 months ago
  • 6.0.1                                ...           4 months ago
  • 6.0.0                                ...           4 months ago
  • 5.7.0                                ...           5 months ago
  • 5.6.9                                ...           5 months ago
  • 5.6.8                                ...           6 months ago
  • 5.6.7                                ...           6 months ago
  • 5.6.6                                ...           6 months ago
  • 5.6.5                                ...           8 months ago
  • 5.6.4                                ...           10 months ago
  • 5.6.3                                ...           10 months ago
  • 5.6.2                                ...           10 months ago
  • 5.6.1                                ...           a year ago
  • 5.6.0                                ...           a year ago
  • 5.5.0                                ...           a year ago
  • 5.4.3                                ...           a year ago
  • 5.4.2                                ...           a year ago
  • 5.4.1                                ...           a year ago
  • 5.4.0                                ...           a year ago
  • 3.7.0                                ...           a year ago
  • 5.3.4                                ...           a year ago
  • 5.3.3                                ...           a year ago
  • 5.3.1                                ...           a year ago
  • 5.3.0                                ...           a year ago
  • 5.2.2                                ...           a year ago
  • 5.2.1                                ...           a year ago
  • 5.2.0                                ...           a year ago
  • 5.1.0                                ...           2 years ago
  • 5.0.5                                ...           2 years ago
  • 5.0.4                                ...           2 years ago
  • 5.0.3                                ...           2 years ago
  • 5.0.2                                ...           2 years ago
  • 4.15.4                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.15.3                                ...           2 years ago
  • 4.15.2                                ...           2 years ago
  • 5.0.0-alpha.2                                ...           2 years ago
  • 5.0.0-alpha.1                                ...           2 years ago
  • 5.0.0-alpha.0                                ...           2 years ago
  • 4.15.1                                ...           2 years ago
  • 4.15.0                                ...           2 years ago
  • 4.14.0                                ...           2 years ago
  • 4.13.0                                ...           3 years ago
  • 4.12.2                                ...           3 years ago
  • 4.12.1                                ...           3 years ago
  • 4.12.0                                ...           3 years ago
  • 4.11.10                                ...           3 years ago
  • 4.11.9                                ...           3 years ago
  • 4.11.8                                ...           3 years ago
  • 4.11.7                                ...           3 years ago
  • 4.11.6                                ...           3 years ago
  • 4.11.5                                ...           3 years ago
  • 4.11.4                                ...           3 years ago
  • 4.11.3                                ...           3 years ago
  • 4.11.2                                ...           3 years ago
  • 4.11.1                                ...           3 years ago
  • 4.11.0                                ...           3 years ago
  • 4.10.1                                ...           3 years ago
  • 4.10.0                                ...           3 years ago
  • 4.9.4                                ...           3 years ago
  • 4.9.3                                ...           3 years ago
  • 4.9.2                                ...           3 years ago
  • 4.9.1                                ...           3 years ago
  • 4.9.0                                ...           3 years ago
  • 4.8.1                                ...           3 years ago
  • 4.8.0                                ...           3 years ago
  • 4.7.2                                ...           3 years ago
  • 4.7.1                                ...           3 years ago
  • 4.7.0                                ...           3 years ago
  • 4.6.1                                ...           3 years ago
  • 4.6.0                                ...           3 years ago
  • 4.5.2                                ...           3 years ago
  • 4.5.1                                ...           3 years ago
  • 4.5.0                                ...           3 years ago
  • 4.4.1                                ...           3 years ago
  • 4.4.0                                ...           3 years ago
  • 4.3.0                                ...           3 years ago
  • 4.2.8                                ...           3 years ago
  • 4.2.7                                ...           3 years ago
  • 4.2.6                                ...           3 years ago
  • 4.2.5                                ...           3 years ago
  • 4.2.4                                ...           3 years ago
  • 4.2.3                                ...           4 years ago
  • 4.2.2                                ...           4 years ago
  • 4.2.1                                ...           4 years ago
  • 4.2.0                                ...           4 years ago
  • 4.1.3                                ...           4 years ago
  • 3.6.0                                ...           4 years ago
  • 4.1.2                                ...           4 years ago
  • 4.1.1                                ...           4 years ago
  • 4.1.0                                ...           4 years ago
  • 4.0.1                                ...           4 years ago
  • 3.5.3                                ...           4 years ago
  • 3.5.2                                ...           4 years ago
  • 3.5.1                                ...           4 years ago
  • 3.5.0                                ...           4 years ago
  • 4.0.0-alpha.6                                ...           4 years ago
  • 4.0.0-alpha.5                                ...           4 years ago
  • 4.0.0-alpha.4                                ...           4 years ago
  • 4.0.0-alpha.3                                ...           4 years ago
  • 4.0.0-alpha.2                                ...           4 years ago
  • 4.0.0-alpha.1                                ...           4 years ago
  • 4.0.0-alpha.0                                ...           4 years ago
  • 3.4.0                                ...           5 years ago
  • 3.3.2                                ...           5 years ago
  • 3.3.1                                ...           5 years ago
  • 3.3.0                                ...           5 years ago
  • 3.2.1                                ...           5 years ago
  • 3.2.0                                ...           5 years ago
  • 3.1.4                                ...           5 years ago
  • 3.1.3                                ...           5 years ago
  • 4.0.0 [deprecated]           ...           5 years ago
  • 3.1.2                                ...           5 years ago
  • 3.1.1                                ...           5 years ago
  • 3.1.0                                ...           5 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.2                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.4.1                                ...           6 years ago
  • 1.4.0                                ...           6 years ago
  • 1.3.1                                ...           6 years ago
  • 1.3.0                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.5                                ...           7 years ago
  • 1.1.3                                ...           7 years ago
  • 1.1.2                                ...           7 years ago
  • 1.1.1 [deprecated]           ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.3-beta.7                                ...           7 years ago
  • 0.1.2-beta.6                                ...           7 years ago
  • 0.1.1-beta.5                                ...           7 years ago
  • 0.1.0-beta.4                                ...           7 years ago
  • 0.0.1-alpha.3                                ...           7 years ago
  • 0.0.1-alpha.2                                ...           7 years ago
  • 0.0.1-alpha.1                                ...           7 years ago
  • 0.0.1-alpha.0                                ...           7 years ago
Downloads
Total 662
Today 1
This Week 36
This Month 343
Last Day 6
Last Week 29
Last Month 219
Dependencies (3)
Dev Dependencies (26)

© 2010 - cnpmjs.org x YWFE | Home | YWFE