Commit 11a7feb8 11a7feb8b02226bdd965821169e739858b975177 by Chris Bosco

Merge branch 'master' of github.com:n1k0/casperjs into request-changeurl

2 parents 325d4880 0799a6b7
......@@ -19,7 +19,6 @@
"predef" : [
"exports",
"phantom",
"require",
"window"
]
}
......
......@@ -2,8 +2,6 @@ docs
modules/vendors
modules/events.js
modules/querystring.js
samples
tests/clitests/tester/
tests/site
tests/testdir
samples/**
tests/**
tmp
......
......@@ -3,7 +3,7 @@ branches:
- "master"
- "1.0"
before_script:
- "npm install -g jshint@0.9.1"
- "npm install -g jshint@1.0.0"
- "phantomjs --version"
- "export PHANTOMJS_EXECUTABLE='phantomjs --local-to-remote-url-access=yes --ignore-ssl-errors=yes'"
script:
......
......@@ -28,8 +28,8 @@
*
*/
/*global console phantom require*/
/*jshint maxstatements:30 maxcomplexity:10*/
/*global console, phantom, require:true*/
/*jshint maxstatements:30, maxcomplexity:10*/
// phantom check
if (!phantom) {
......
......@@ -56,5 +56,5 @@ CASPER_COMMAND.extend(CASPER_ARGS)
try:
os.execvp(CASPER_COMMAND[0], CASPER_COMMAND)
except OSError as err:
print(('Fatal: %s; did you install phantomjs?' % err))
print('Fatal: %s; did you install phantomjs?' % err)
sys.exit(1)
......
......@@ -28,7 +28,7 @@
*
*/
/*global CasperError console exports phantom __utils__ patchRequire*/
/*global CasperError, console, exports, phantom, __utils__, patchRequire*/
var require = patchRequire(require);
var colorizer = require('colorizer');
......@@ -1883,6 +1883,26 @@ Casper.prototype.waitForText = function(pattern, then, onTimeout, timeout) {
};
/**
* Waits until the text on an element matching the provided DOM CSS3/XPath selector
* is changed to a different value.
*
* @param String selector A DOM CSS3/XPath selector
* @param Function then The next step to preform (optional)
* @param Function onTimeout A callback function to call on timeout (optional)
* @param Number timeout The max amount of time to wait, in milliseconds (optional)
* @return Casper
*/
Casper.prototype.waitForSelectorTextChange = function(selector, then, onTimeout, timeout) {
"use strict";
this.checkStarted();
timeout = timeout ? timeout : this.options.waitTimeout;
var currentSelectorText = this.fetchText(selector);
return this.waitFor(function _check() {
return currentSelectorText !== this.fetchText(selector);
}, then, onTimeout, timeout);
};
/**
* Waits until an element matching the provided DOM CSS3/XPath selector does not
* exist in the remote DOM to process a next step.
*
......
......@@ -28,7 +28,7 @@
*
*/
/*global CasperError console exports phantom patchRequire*/
/*global CasperError, console, exports, phantom, patchRequire*/
var require = patchRequire(require);
var utils = require('utils');
......
......@@ -28,7 +28,7 @@
*
*/
/*global console escape exports NodeList window*/
/*global console, escape, exports, NodeList, window*/
(function(exports) {
"use strict";
......@@ -76,7 +76,7 @@
* @return string
*/
this.decode = function decode(str) {
/*jshint maxstatements:30 maxcomplexity:30 */
/*jshint maxstatements:30, maxcomplexity:30 */
var c1, c2, c3, c4, i = 0, len = str.length, out = "";
while (i < len) {
do {
......
......@@ -28,7 +28,7 @@
*
*/
/*global exports console patchRequire*/
/*global exports, console, patchRequire*/
var require = patchRequire(require);
var fs = require('fs');
......
......@@ -28,7 +28,7 @@
*
*/
/*global CasperError exports patchRequire*/
/*global CasperError, exports, patchRequire*/
var require = patchRequire(require);
var utils = require('utils');
......
......@@ -28,7 +28,7 @@
*
*/
/*global CasperError console exports phantom patchRequire*/
/*global CasperError, console, exports, phantom, patchRequire*/
var require = patchRequire(require);
var utils = require('utils');
......
......@@ -28,7 +28,7 @@
*
*/
/*global CasperError exports phantom __utils__ patchRequire*/
/*global CasperError, exports, phantom, __utils__, patchRequire*/
var require = patchRequire(require);
var fs = require('fs');
......@@ -666,13 +666,15 @@ Tester.prototype.assertFalsy = function assertFalsy(subject, message) {
Tester.prototype.assertSelectorHasText =
Tester.prototype.assertSelectorContains = function assertSelectorHasText(selector, text, message) {
"use strict";
var textFound = this.casper.fetchText(selector).indexOf(text) !== -1;
var got = this.casper.fetchText(selector);
var textFound = got.indexOf(text) !== -1;
return this.assert(textFound, message, {
type: "assertSelectorHasText",
standard: f('Found "%s" within the selector "%s"', text, selector),
values: {
selector: selector,
text: text
text: text,
actualContent: got
}
});
};
......@@ -922,7 +924,7 @@ Tester.prototype.comment = function comment(message) {
*/
Tester.prototype.done = function done() {
"use strict";
/*jshint maxstatements:20 maxcomplexity:20*/
/*jshint maxstatements:20, maxcomplexity:20*/
var planned, config = this.currentSuite.config;
if (utils.isNumber(arguments[0])) {
this.casper.warn('done() `planned` arg is deprecated as of 1.1');
......
......@@ -28,7 +28,7 @@
*
*/
/*global CasperError console exports phantom patchRequire*/
/*global CasperError, console, exports, phantom, patchRequire*/
var require = patchRequire(require);
......
......@@ -28,7 +28,7 @@
*
*/
/*global CasperError console exports phantom patchRequire*/
/*global CasperError, console, exports, phantom, patchRequire*/
var require = patchRequire(require);
var utils = require('utils');
......@@ -166,5 +166,6 @@ XUnitExporter.prototype.setResults = function setResults(results) {
if (!(results instanceof TestSuiteResult)) {
throw new CasperError('Invalid results type.');
}
return this.results = results;
this.results = results;
return results;
};
......
......@@ -11,11 +11,15 @@
<li>two</li>
<li>three</li>
</ul>
<div id="textChange" >
Loading...
</div>
<script>
setTimeout(function() {
var li = document.createElement('li')
li.appendChild(document.createTextNode('four'));
document.querySelector('ul').appendChild(li);
document.getElementById('textChange').innerHTML = 'Done';
}, 500);
</script>
</body>
......
......@@ -87,9 +87,23 @@ casper.test.begin('waitForText() tests', 2, function(test) {
});
casper.reload().waitForText(/four/i, function() {
this.test.pass('Casper.waitForText() can wait for regexp');
test.pass('Casper.waitForText() can wait for regexp');
}, function() {
this.test.fail('Casper.waitForText() can wait for regexp');
test.fail('Casper.waitForText() can wait for regexp');
});
casper.run(function() {
test.done();
});
});
casper.test.begin('waitForSelectorTextChange() tests', 1, function(test) {
casper.start('tests/site/waitFor.html');
casper.waitForSelectorTextChange('#textChange', function() {
test.pass('Casper.waitForSelectorTextChange() can wait for text on a selector to change');
}, function() {
test.fail('Casper.waitForSelectorTextChange() can wait for text on a selector to change');
});
casper.run(function() {
......