chai-webdriverio
Provides webdriverio sugar for the Chai assertion library. Allows you to create expressive integration tests:
1 | expect('.frequency-field').to.have.text('One time') |
What sorts of assertions can we make?
All assertions start with a WebdriverIO-compatible selector, 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 the element exists.expect(selector).to.be.visible()
- Test whether or not the element is visible.expect(selector).to.have.text('string')
- Test the text value of the dom element against supplied string. Exact matches only.expect(selector).to.have.text(/regex/)
- Test the text value of the dom element against the supplied regular expression.expect(selector).to.have.count(number)
- Test how many elements exist in the dom with the supplied selector
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:
1 | var chai = require('chai'); |
Contributing
so easy.
1 | npm # download the necessary development dependencies |
Contributors:
- @mltsy :
exist
,text
assertions, documentation & test adjustments
License
Apache 2.0
Thanks
Thanks to goodeggs for creating: chai-webdriver which inspired this module.