New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chai-webdriver

Package Overview
Dependencies
Maintainers
4
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-webdriver

Build more expressive integration tests with some webdriver sugar for chai.js

  • 0.5.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

chai-webdriver Build Status Dependency Status NPM version

Provides selenium-webdriver sugar for the Chai assertion library. Allows you to create expressive integration tests:

expect('.frequency-field').dom.to.contain.text('One time')
expect('.toggle-pane').dom.to.not.be.visible()

What sorts of assertions can we make?

All assertions start with a Sizzle-compatible css selector, for example:

  • expect('.list')
  • expect('div > h1')
  • expect('a[href=http://google.com]')

Then we add the dom flag, like so:

  • expect(selector).dom

Finally, we can add our assertion to the chain:

  • expect(selector).dom.to.have.text('string') - Test the text value of the dom against supplied string. Exact matches only.
  • expect(selector).dom.to.contains.text('string') - Test the text value of the dom against supplied string. Partial matches allowed.
  • expect(selector).dom.to.be.visible() - Check whether or not the element is being rendered
  • expect(selector).dom.to.be.disabled() - Check whether or not the form element is disabled
  • expect(selector).dom.to.have.count(number) - Test how many elements exist in the dom with the supplied selector
  • expect(selector).dom.to.have.style('property', 'value') - Test the CSS style of the element. Exact matches only, unfortunately, for now.
  • expect(selector).dom.to.have.value('string') - Test the value of a form field against supplied string.
  • expect(selector).dom.to.have.htmlClass('warning') - Tests that the element has warning as one of its class attributes.

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

  • expect(selector).dom.not.to.have.style('property', 'value')

Setup

Setup is pretty easy. Just:


// Start with a webdriver instance:
var sw = require('selenium-webdriver');
var driver = new sw.Builder()
  .withCapabilities(sw.Capabilities.chrome())
  .build()

// And then...
var chai = require('chai');
var chaiWebdriver = require('chai-webdriver');
chai.use chaiWebdriver(driver);

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

Contributing

so easy.

npm install           # download the neccesary development dependencies
npm run-script build  # compile coffee-script into javascript
npm test              # build and run the specs

License

MIT.

Keywords

FAQs

Package last updated on 20 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc