# chai-webdriverio

> Chai assertions for use with webdriverio

Latest version **1.0.0** (published 2019-03-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install chai-webdriverio
pnpm add chai-webdriverio
yarn add chai-webdriverio
bun add chai-webdriverio
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-03-19 |
| First published | 2017-03-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 8.11.0 |
| Dependencies | 0 |
| Unpacked size | 172 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Marco De Jongh |
| Maintainers | mdejongh, mltsy |
| Keywords | webdriverio, webdriver, chai, chai matchers, assertion helpers |

## Links

- npm: https://www.npmjs.com/package/chai-webdriverio
- Repository: https://github.com/marcodejongh/chai-webdriverio
- Homepage: https://github.com/marcodejongh/chai-webdriverio#readme
- Issues: https://github.com/marcodejongh/chai-webdriverio/issues
- npm.io page: https://npm.io/package/chai-webdriverio

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-03-19
- 0.4.3 — 2017-11-13
- 0.4.2 — 2017-07-28
- 0.4.1 — 2017-07-03
- 0.4.0 — 2017-06-15
- 0.3.0 — 2017-04-04
- 0.2.0 — 2017-03-21
- 0.1.0 — 2017-03-19
- 0.0.5 — 2017-03-19
- 0.0.4 — 2017-03-19
- 0.0.3 — 2017-03-17
- 0.0.2 — 2017-03-15

## README

# chai-webdriverio ![Travis badge](https://travis-ci.org/marcodejongh/chai-webdriverio.svg?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/marcodejongh/chai-webdriverio.svg)](https://greenkeeper.io/)



Provides [webdriverio](https://npmjs.org/package/webdriverio) sugar for the [Chai](http://chaijs.com/) assertion library. Allows you to create expressive integration tests:

```javascript
expect('.frequency-field').to.have.text('One time')
expect('.toggle-pane').to.not.be.displayed()
```

## What sorts of assertions can we make?

All assertions start with a [WebdriverIO-compatible selector](http://webdriver.io/guide/usage/selectors.html), for example:

- `expect('.list')` (CSS selector)
- `expect('a[href=http://google.com]')` (CSS Selector)
- `expect('//BODY/DIV[6]/DIV[1]')` (XPath selector)
- `expect('a*=Save')` (Text selector)

Then, we can add our assertion to the chain.

- `expect(selector).to.be.there()` - Test whether [at least one] matching element exists in the DOM
- `expect(selector).to.be.displayed()` - Test whether or not [at least one] matching element is displayed
- `expect(selector).to.have.text('string')` - Test the text value of the selected element(s) against supplied string. Succeeds if at least one element matches exactly
- `expect(selector).to.have.text(/regex/)` - Test the text value of the selected element(s) against the supplied regular expression. Succeeds if at least one element matches
- `expect(selector).to.have.count(number)` - Test how many elements exist in the DOM with the supplied selector
- `expect(selector).to.have.value('x')` - Test that [at least one] selected element has the given value
- `expect(selector).to.have.focus()` - Test that [at least one] selected element has focus

You can also always add a `not` in there to negate the assertion:

- `expect(selector).not.to.have.text('property')`

## Setup

Setup is pretty easy. Just:

```javascript
var chai = require('chai');
var chaiWebdriver = require('chai-webdriverio').default;
chai.use(chaiWebdriver(browser));

// And you're good to go!
browser.url('http://github.com');
chai.expect('#site-container h1.heading').to.not.contain.text("I'm a kitty!");
```

## Default Wait Time

As an optional argument to the initializer, you can add an `options` object in this format:

```javascript
var options = {defaultWait: 500} // 500ms
chai.use(chaiWebdriver(browser, options));
```

The `defaultWait` parameter will cause chai-webdriverio to wait the specified number of milliseconds
for a given selector to appear before failing (if it is not yet present on the page).  You can use `immediately`
to skip this default wait time:

```javascript
expect(selector).to.immediately.have.text('string'); // fails immediately if element is not found
```

**Beware:** For `immediately` to work, your [implicit wait time in WebdriverIO](http://webdriver.io/guide/testrunner/timeouts.html#Session-Implicit-Wait-Timeout)
must be set to 0.  The immediately flag has no way to skip WebdriverIO's implicit wait.

## Compatability

### WebdriverIO
| WebdriverIO version | Compatible `chai-webdriverio` version |
| ---- | ---- |
| 5.x.x | >= 1.0.0
| 4.x.x | 0.4.3

### Node.js

`chai-webdriverio` version >= 1.0.0 requires Node.js 8.x

## Contributing

so easy.

```bash
npm                # download the necessary development dependencies
npm transpile      # compile ES6 into javascript
npm test           # build and run the specs
```

**Contributors:**

* [@mltsy](https://github.com/mltsy) : `exist`, `text` assertions, documentation & test adjustments

## License

Apache 2.0

## Thanks
Thanks to [goodeggs](https://github.com/goodeggs/) for creating: [chai-webdriver](https://github.com/goodeggs/chai-webdriver) which inspired this module.

---
_Source: https://npm.io/package/chai-webdriverio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
