Skip to content

Commit

Permalink
Docs. Readding setValue method.
Browse files Browse the repository at this point in the history
  • Loading branch information
asciidisco committed Aug 1, 2013
1 parent e043f5b commit 0157561
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var Actions = function () {
* .done();
* ```
*
* you can write this instead
* you can write this:
*
* ```javascript
* test.open('http://doctorwhotv.co.uk/')
Expand All @@ -74,6 +74,8 @@ var Actions = function () {
* .done();
* ```
*
* Always make sure, you terminate it with the [assertions.html#meth-end](end) method!
*
* @api
* @method query
* @param {string} selector Selector of the element to query
Expand Down Expand Up @@ -180,7 +182,7 @@ Actions.prototype.setHttpAuth = function (username, password) {
* than switches to the iframe context, every action and assertion will be executed within the iFrame context.
* Btw.: The domain of the IFrame can be whatever you want, this method has no same origin policy restrictions.
*
* If you wan't to get back to the parents context, you have to use the [#meth-toParent"](toParent) method.
* If you wan't to get back to the parents context, you have to use the [toParent](#meth-toParent) method.
*
* ```html
* <div>
Expand Down Expand Up @@ -255,7 +257,7 @@ Actions.prototype.toParent = function () {
* than switches to the window context, every action and assertion will be executed within the chosen window context.
* Btw.: The domain of the window can be whatever you want, this method has no same origin policy restrictions.
*
* If you want to get back to the parents context, you have to use the [#meth-toParentWindow"](toParentWindow) method.
* If you want to get back to the parents context, you have to use the [toParentWindow](#meth-toParentWindow) method.
*
* ```html
* <div>
Expand Down Expand Up @@ -955,6 +957,12 @@ Actions.prototype.setCookie = function (name, contents) {

Actions.prototype.waitForElement = function (selector, timeout) {
var hash = uuid.v4();

if (this.querying === true) {
timeout = selector;
selector = this.selector;
}

var cb = this._generateCallbackAssertion('waitForElement', 'waitForElement', selector + ' : ' + timeout, hash);
this._addToActionQueue([selector, (timeout ? parseInt(timeout, 10) : 5000), hash], 'waitForElement', cb);
return this;
Expand Down Expand Up @@ -990,6 +998,39 @@ Actions.prototype._generateCallbackAssertion = function (key, type) {
return cb;
};

/**
* Fills the fields of a form with given values.
*
* ```html
* <input type="hidden" value="not really a value" id="ijustwannahaveavalue"/>
* ```
*
* ```javascript
* test.open('http://dalekjs.com')
* .setValue('#ijustwannahaveavalue', 'a value')
* .title().is('DalekJS - Frequently asked questions', 'What the F.A.Q.');
* ```
*
* @api
* @method setValue
* @param {string} selector
* @param {string} value
* @return {Actions}
*/

Actions.prototype.setValue = function (selector, value) {
var hash = uuid.v4();

if (this.querying === true) {
value = selector;
selector = this.selector;
}

var cb = this._generateCallbackAssertion('setValue', 'setValue', selector + ' : ' + value, hash);
this._addToActionQueue([selector, value, hash], 'setValue', cb);
return this;
};

/**
* Adds a method to the queue of actions/assertions to execute
*
Expand Down

0 comments on commit 0157561

Please sign in to comment.