Skip to content

Commit 0157561

Browse files
committed
Docs. Readding setValue method.
1 parent e043f5b commit 0157561

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

index.js

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var Actions = function () {
6161
* .done();
6262
* ```
6363
*
64-
* you can write this instead
64+
* you can write this:
6565
*
6666
* ```javascript
6767
* test.open('http://doctorwhotv.co.uk/')
@@ -74,6 +74,8 @@ var Actions = function () {
7474
* .done();
7575
* ```
7676
*
77+
* Always make sure, you terminate it with the [assertions.html#meth-end](end) method!
78+
*
7779
* @api
7880
* @method query
7981
* @param {string} selector Selector of the element to query
@@ -180,7 +182,7 @@ Actions.prototype.setHttpAuth = function (username, password) {
180182
* than switches to the iframe context, every action and assertion will be executed within the iFrame context.
181183
* Btw.: The domain of the IFrame can be whatever you want, this method has no same origin policy restrictions.
182184
*
183-
* If you wan't to get back to the parents context, you have to use the [#meth-toParent"](toParent) method.
185+
* If you wan't to get back to the parents context, you have to use the [toParent](#meth-toParent) method.
184186
*
185187
* ```html
186188
* <div>
@@ -255,7 +257,7 @@ Actions.prototype.toParent = function () {
255257
* than switches to the window context, every action and assertion will be executed within the chosen window context.
256258
* Btw.: The domain of the window can be whatever you want, this method has no same origin policy restrictions.
257259
*
258-
* If you want to get back to the parents context, you have to use the [#meth-toParentWindow"](toParentWindow) method.
260+
* If you want to get back to the parents context, you have to use the [toParentWindow](#meth-toParentWindow) method.
259261
*
260262
* ```html
261263
* <div>
@@ -955,6 +957,12 @@ Actions.prototype.setCookie = function (name, contents) {
955957

956958
Actions.prototype.waitForElement = function (selector, timeout) {
957959
var hash = uuid.v4();
960+
961+
if (this.querying === true) {
962+
timeout = selector;
963+
selector = this.selector;
964+
}
965+
958966
var cb = this._generateCallbackAssertion('waitForElement', 'waitForElement', selector + ' : ' + timeout, hash);
959967
this._addToActionQueue([selector, (timeout ? parseInt(timeout, 10) : 5000), hash], 'waitForElement', cb);
960968
return this;
@@ -990,6 +998,39 @@ Actions.prototype._generateCallbackAssertion = function (key, type) {
990998
return cb;
991999
};
9921000

1001+
/**
1002+
* Fills the fields of a form with given values.
1003+
*
1004+
* ```html
1005+
* <input type="hidden" value="not really a value" id="ijustwannahaveavalue"/>
1006+
* ```
1007+
*
1008+
* ```javascript
1009+
* test.open('http://dalekjs.com')
1010+
* .setValue('#ijustwannahaveavalue', 'a value')
1011+
* .title().is('DalekJS - Frequently asked questions', 'What the F.A.Q.');
1012+
* ```
1013+
*
1014+
* @api
1015+
* @method setValue
1016+
* @param {string} selector
1017+
* @param {string} value
1018+
* @return {Actions}
1019+
*/
1020+
1021+
Actions.prototype.setValue = function (selector, value) {
1022+
var hash = uuid.v4();
1023+
1024+
if (this.querying === true) {
1025+
value = selector;
1026+
selector = this.selector;
1027+
}
1028+
1029+
var cb = this._generateCallbackAssertion('setValue', 'setValue', selector + ' : ' + value, hash);
1030+
this._addToActionQueue([selector, value, hash], 'setValue', cb);
1031+
return this;
1032+
};
1033+
9931034
/**
9941035
* Adds a method to the queue of actions/assertions to execute
9951036
*

0 commit comments

Comments
 (0)