fixes #220, #237 - added a waitTimeout options
Showing
2 changed files
with
10 additions
and
9 deletions
... | @@ -8,6 +8,7 @@ This version is yet to be released. | ... | @@ -8,6 +8,7 @@ This version is yet to be released. |
8 | 8 | ||
9 | ### Important Changes & Caveats | 9 | ### Important Changes & Caveats |
10 | 10 | ||
11 | **BC BREAK**: - fixes [#220](https://github.com/n1k0/casperjs/issues/220), [#237](https://github.com/n1k0/casperjs/issues/237) - added a `waitTimeout` options, removed `defaultWaitTimeout` option. | ||
11 | **BC BREAK** (for the better): merged [#188](https://github.com/n1k0/casperjs/issues/188) - Easy access to current response object; | 12 | **BC BREAK** (for the better): merged [#188](https://github.com/n1k0/casperjs/issues/188) - Easy access to current response object; |
12 | You can now access the current response object as the first parameter of step callbacks: | 13 | You can now access the current response object as the first parameter of step callbacks: |
13 | 14 | ... | ... |
... | @@ -103,7 +103,8 @@ var Casper = function Casper(options) { | ... | @@ -103,7 +103,8 @@ var Casper = function Casper(options) { |
103 | }, | 103 | }, |
104 | stepTimeout: null, | 104 | stepTimeout: null, |
105 | timeout: null, | 105 | timeout: null, |
106 | verbose: false | 106 | verbose: false, |
107 | waitTimeout: 5000 | ||
107 | }; | 108 | }; |
108 | // options | 109 | // options |
109 | this.options = utils.mergeObjects(this.defaults, options); | 110 | this.options = utils.mergeObjects(this.defaults, options); |
... | @@ -114,7 +115,6 @@ var Casper = function Casper(options) { | ... | @@ -114,7 +115,6 @@ var Casper = function Casper(options) { |
114 | this.currentResponse = undefined; | 115 | this.currentResponse = undefined; |
115 | this.currentUrl = 'about:blank'; | 116 | this.currentUrl = 'about:blank'; |
116 | this.currentHTTPStatus = null; | 117 | this.currentHTTPStatus = null; |
117 | this.defaultWaitTimeout = 5000; | ||
118 | this.history = []; | 118 | this.history = []; |
119 | this.loadInProgress = false; | 119 | this.loadInProgress = false; |
120 | this.navigationRequested = false; | 120 | this.navigationRequested = false; |
... | @@ -1244,7 +1244,7 @@ Casper.prototype.start = function start(location, then) { | ... | @@ -1244,7 +1244,7 @@ Casper.prototype.start = function start(location, then) { |
1244 | * @return Object | 1244 | * @return Object |
1245 | */ | 1245 | */ |
1246 | Casper.prototype.status = function status(asString) { | 1246 | Casper.prototype.status = function status(asString) { |
1247 | var properties = ['currentHTTPStatus', 'defaultWaitTimeout', 'loadInProgress', 'navigationRequested', | 1247 | var properties = ['currentHTTPStatus', 'loadInProgress', 'navigationRequested', |
1248 | 'options', 'pendingWait', 'requestUrl', 'started', 'step', 'url']; | 1248 | 'options', 'pendingWait', 'requestUrl', 'started', 'step', 'url']; |
1249 | var currentStatus = {}; | 1249 | var currentStatus = {}; |
1250 | properties.forEach(function(property) { | 1250 | properties.forEach(function(property) { |
... | @@ -1491,7 +1491,7 @@ Casper.prototype.waitDone = function waitDone() { | ... | @@ -1491,7 +1491,7 @@ Casper.prototype.waitDone = function waitDone() { |
1491 | */ | 1491 | */ |
1492 | Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { | 1492 | Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { |
1493 | "use strict"; | 1493 | "use strict"; |
1494 | timeout = timeout ? timeout : this.defaultWaitTimeout; | 1494 | timeout = timeout ? timeout : this.options.waitTimeout; |
1495 | if (!utils.isFunction(testFx)) { | 1495 | if (!utils.isFunction(testFx)) { |
1496 | this.die("waitFor() needs a test function"); | 1496 | this.die("waitFor() needs a test function"); |
1497 | } | 1497 | } |
... | @@ -1539,7 +1539,7 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { | ... | @@ -1539,7 +1539,7 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { |
1539 | */ | 1539 | */ |
1540 | Casper.prototype.waitForResource = function waitForResource(test, then, onTimeout, timeout) { | 1540 | Casper.prototype.waitForResource = function waitForResource(test, then, onTimeout, timeout) { |
1541 | "use strict"; | 1541 | "use strict"; |
1542 | timeout = timeout ? timeout : this.defaultWaitTimeout; | 1542 | timeout = timeout ? timeout : this.options.waitTimeout; |
1543 | return this.waitFor(function _check() { | 1543 | return this.waitFor(function _check() { |
1544 | return this.resourceExists(test); | 1544 | return this.resourceExists(test); |
1545 | }, then, onTimeout, timeout); | 1545 | }, then, onTimeout, timeout); |
... | @@ -1557,7 +1557,7 @@ Casper.prototype.waitForResource = function waitForResource(test, then, onTimeou | ... | @@ -1557,7 +1557,7 @@ Casper.prototype.waitForResource = function waitForResource(test, then, onTimeou |
1557 | */ | 1557 | */ |
1558 | Casper.prototype.waitForSelector = function waitForSelector(selector, then, onTimeout, timeout) { | 1558 | Casper.prototype.waitForSelector = function waitForSelector(selector, then, onTimeout, timeout) { |
1559 | "use strict"; | 1559 | "use strict"; |
1560 | timeout = timeout ? timeout : this.defaultWaitTimeout; | 1560 | timeout = timeout ? timeout : this.options.waitTimeout; |
1561 | return this.waitFor(function _check() { | 1561 | return this.waitFor(function _check() { |
1562 | return this.exists(selector); | 1562 | return this.exists(selector); |
1563 | }, then, onTimeout, timeout); | 1563 | }, then, onTimeout, timeout); |
... | @@ -1575,7 +1575,7 @@ Casper.prototype.waitForSelector = function waitForSelector(selector, then, onTi | ... | @@ -1575,7 +1575,7 @@ Casper.prototype.waitForSelector = function waitForSelector(selector, then, onTi |
1575 | */ | 1575 | */ |
1576 | Casper.prototype.waitWhileSelector = function waitWhileSelector(selector, then, onTimeout, timeout) { | 1576 | Casper.prototype.waitWhileSelector = function waitWhileSelector(selector, then, onTimeout, timeout) { |
1577 | "use strict"; | 1577 | "use strict"; |
1578 | timeout = timeout ? timeout : this.defaultWaitTimeout; | 1578 | timeout = timeout ? timeout : this.options.waitTimeout; |
1579 | return this.waitFor(function _check() { | 1579 | return this.waitFor(function _check() { |
1580 | return !this.exists(selector); | 1580 | return !this.exists(selector); |
1581 | }, then, onTimeout, timeout); | 1581 | }, then, onTimeout, timeout); |
... | @@ -1593,7 +1593,7 @@ Casper.prototype.waitWhileSelector = function waitWhileSelector(selector, then, | ... | @@ -1593,7 +1593,7 @@ Casper.prototype.waitWhileSelector = function waitWhileSelector(selector, then, |
1593 | */ | 1593 | */ |
1594 | Casper.prototype.waitUntilVisible = function waitUntilVisible(selector, then, onTimeout, timeout) { | 1594 | Casper.prototype.waitUntilVisible = function waitUntilVisible(selector, then, onTimeout, timeout) { |
1595 | "use strict"; | 1595 | "use strict"; |
1596 | timeout = timeout ? timeout : this.defaultWaitTimeout; | 1596 | timeout = timeout ? timeout : this.options.waitTimeout; |
1597 | return this.waitFor(function _check() { | 1597 | return this.waitFor(function _check() { |
1598 | return this.visible(selector); | 1598 | return this.visible(selector); |
1599 | }, then, onTimeout, timeout); | 1599 | }, then, onTimeout, timeout); |
... | @@ -1611,7 +1611,7 @@ Casper.prototype.waitUntilVisible = function waitUntilVisible(selector, then, on | ... | @@ -1611,7 +1611,7 @@ Casper.prototype.waitUntilVisible = function waitUntilVisible(selector, then, on |
1611 | */ | 1611 | */ |
1612 | Casper.prototype.waitWhileVisible = function waitWhileVisible(selector, then, onTimeout, timeout) { | 1612 | Casper.prototype.waitWhileVisible = function waitWhileVisible(selector, then, onTimeout, timeout) { |
1613 | "use strict"; | 1613 | "use strict"; |
1614 | timeout = timeout ? timeout : this.defaultWaitTimeout; | 1614 | timeout = timeout ? timeout : this.options.waitTimeout; |
1615 | return this.waitFor(function _check() { | 1615 | return this.waitFor(function _check() { |
1616 | return !this.visible(selector); | 1616 | return !this.visible(selector); |
1617 | }, then, onTimeout, timeout); | 1617 | }, then, onTimeout, timeout); | ... | ... |
-
Please register or sign in to post a comment