diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 8aa349a..fcf44b7 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -2,7 +2,7 @@ config = jshint: all: [ - 'tasks/**/*.js' + 'index.js' ], options: jshintrc: '.jshintrc' diff --git a/README.md b/README.md index 7bfd368..2434786 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ wd-query ======== -jQuery style selectors for [wd](https://github.com/admc/wd). +v0.0.3 + +jQuery style selectors for [wd](https://github.com/admc/wd) promises. ### tl;dr @@ -33,6 +35,9 @@ Because selector's make sense and so does chaining. Approaching selenium webdriver interactions as starting with selectors makes it easy to combine multi-step sequences into terse and expressive statements. +By mapping wd's webdirver API in chainable constructor, a jQuery-esque API is +possible with very little code. This is not jQuery. It just looks like it. + ### Why wd promises? Because the nested callback style is unruly for anything complex. Promises are @@ -40,3 +45,51 @@ also portable--they can be easily passed around between functions and scopes. By using the wd promise interface wd-query is able to chain multiple async calls into a unified, selector-driven syntax. + +### Usage + +To use, just pass an initialized wd instance (called `browser` by +convention) to the function exported by wd-query. Note that you must be use +`wd.promiseRemote`. + +```javascript +var wd = require('wd'); +var wdQuery = require('wd-query'); + +var browser = wd.promiseRemote( ... ); +var $ = wdQuery(browser); + +browser.init() + .then(function(){ + return $('.open-modal').click() + }) + .then(function(){ + return $('#modal').get(); + }) + .then(function(elem){ + assert.ok(elem) + browser.quit(); + }); +``` + +If you've already called `browser.init()`, for instance at the start of your +test suite, calls to wd-query instances can begin a promise chain. + +```javascript +$('.open-modal').click().then( ... ) +``` + +### Goals + +The ultimate goal is to have pairity with the wd API for all actions that work +with css selectors while adding support for selecting multiple elements. + +### Contributing + +This is a need-based project, so I only wrote it to account for my needs as of +right now. If you have suggestestions, opinions, optimizations or fixes, +please fork and pull request to contribute. + +### License + +MIT diff --git a/package.json b/package.json index 6b7ee8b..9d72349 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wd-query", - "version": "0.0.2", + "version": "0.0.3", "description": "A jQuery-esue wrapper for wd", "main": "index.js", "scripts": {