WebdriverIO Assertion library inspired by expect
npm install expect
(Jasmine and Jest users should skip this step)npm install expect-webdriverio
NOTE: WebdriverIO v9.0.0
or higher is required!
If you run your tests through the WDIO testrunner no additional setup is needed. WebdriverIO initialises expect-webdriverio
and makes expect
available in the global scope. So you can use it directly in your tests:
const $button = await $('button')
await expect($button).toBeDisplayed()
See more Examples
If you embed WebdriverIO in a standalone script, make sure you import expect-webdriverio
before you use 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.$('button')
await expect($button).toBeDisplayed()
await browser.deleteSession()
})().catch(console.error)
Please see API doc
Error messages are informative out of the box and contain:
$('form').$('input')
First of all, feel free to raise an issue with your suggestions or help with PR!