Commit 95b0ff50 95b0ff5012b23442c307e13acad12d1ef1b0fe21 by Nicolas Perriault

sync with master

2 parents f8517450 4fedbaae
......@@ -4,9 +4,12 @@ CasperJS Changelog
XXXX-XX-XX, v1.0.0
------------------
- fixed [#215](https://github.com/n1k0/casperjs/issues/215) - fixed broken `--fail-fast` option creating an endless loop on error
- fixed `page.initialized` event didn't get the initialized `WebPage` instance
- fixed a bug preventing `Casper.options.onPageInitialized()` from being called
- fixed [#215](https://github.com/n1k0/casperjs/issues/215) - fixed broken `--fail-fast` option creating an endless loop on error
- fixed `Tester.renderFailureDetails()` which couldn't print failure details correctly in certain circumstances
- fixed `Casper.getHTML()` wasn't retrieving active frame contents when using `Casper.withFrame()`
- fixed [#327](https://github.com/n1k0/casperjs/issues/327) - event handler for `page.confirm` always returns true
- merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in `Casper.withFrame()`
- fixed [#323](https://github.com/n1k0/casperjs/issues/323) - `thenEvaluate()` should be updated to take the same parameters as `evaluate()`, while maintaining backwards compatibility.
- merged PR [#319](https://github.com/n1k0/casperjs/pull/319), fixed [#209](https://github.com/n1k0/casperjs/issues/209) - test duration has been added to XUnit XML result file.
......
......@@ -810,7 +810,8 @@ Casper.prototype.getCurrentUrl = function getCurrentUrl() {
* @param String attribute The attribute name to lookup
* @return String The requested DOM element attribute value
*/
Casper.prototype.getElementAttribute = Casper.prototype.getElementAttr = function getElementAttr(selector, attribute) {
Casper.prototype.getElementAttribute =
Casper.prototype.getElementAttr = function getElementAttr(selector, attribute) {
"use strict";
this.checkStarted();
return this.evaluate(function _evaluate(selector, attribute) {
......@@ -2027,9 +2028,9 @@ function createPage(casper) {
casper.emit('page.error', msg, trace);
};
page.onInitialized = function onInitialized() {
casper.emit('page.initialized', this);
casper.emit('page.initialized', page);
if (utils.isFunction(casper.options.onPageInitialized)) {
this.log("Post-configuring WebPage instance", "debug");
casper.log("Post-configuring WebPage instance", "debug");
casper.options.onPageInitialized.call(casper, page);
}
};
......
......@@ -59,4 +59,4 @@ if system(CASPER_COMMAND.join(" ")).nil?
puts "Fatal: Did you install phantomjs?"
end
exit $?.exitstatus
exit $?.exitstatus || 1
......
......@@ -11,7 +11,7 @@ images = []
casper.hide = (selector) ->
@evaluate (selector) ->
document.querySelector(selector).style.display = "none"
, selector: selector
, selector
casper.start "http://www.bbc.co.uk/", ->
nbLinks = @evaluate ->
......@@ -21,15 +21,16 @@ casper.start "http://www.bbc.co.uk/", ->
@hide ".nav_left"
@hide ".nav_right"
@mouse.move "#promo2_carousel"
@waitUntilVisible ".autoplay.nav_pause", ->
@echo "Moving over pause button"
@mouse.move ".autoplay.nav_pause"
@click ".autoplay.nav_pause"
@echo "Clicked on pause button"
@waitUntilVisible ".autoplay.nav_play", ->
@echo "Carousel has been paused"
# hide play button
@hide ".autoplay"
casper.waitUntilVisible ".autoplay.nav_pause", ->
@echo "Moving over pause button"
@mouse.move ".autoplay.nav_pause"
@click ".autoplay.nav_pause"
@echo "Clicked on pause button"
@waitUntilVisible ".autoplay.nav_play", ->
@echo "Carousel has been paused"
# hide play button
@hide ".autoplay"
# Capture carrousel area
next = ->
......
......@@ -14,9 +14,7 @@ var buildPage, next;
casper.hide = function(selector) {
this.evaluate(function(selector) {
document.querySelector(selector).style.display = "none";
}, {
selector: selector
});
}, selector);
};
casper.start("http://www.bbc.co.uk/", function() {
......@@ -28,16 +26,17 @@ casper.start("http://www.bbc.co.uk/", function() {
this.hide(".nav_left");
this.hide(".nav_right");
this.mouse.move("#promo2_carousel");
this.waitUntilVisible(".autoplay.nav_pause", function() {
this.echo("Moving over pause button");
this.mouse.move(".autoplay.nav_pause");
this.click(".autoplay.nav_pause");
this.echo("Clicked on pause button");
this.waitUntilVisible(".autoplay.nav_play", function() {
this.echo("Carousel has been paused");
// hide play button
this.hide(".autoplay");
});
});
casper.waitUntilVisible(".autoplay.nav_pause", function() {
this.echo("Moving over pause button");
this.mouse.move(".autoplay.nav_pause");
this.click(".autoplay.nav_pause");
this.echo("Clicked on pause button");
this.waitUntilVisible(".autoplay.nav_play", function() {
this.echo("Carousel has been paused");
// hide play button
this.hide(".autoplay");
});
});
......
......@@ -2,29 +2,27 @@
A basic custom logging implementation. The idea is to (extremely) verbosely
log every received resource.
###
casper = require("casper").create
###
Every time a resource is received, a new log entry is added to the stack
at the 'verbose' level.
@param Object resource A phantomjs resource object
###
onResourceReceived: (self, resource) ->
infos = []
props = [
"url"
"status"
"statusText"
"redirectURL"
"bodySize"
]
infos.push resource[prop] for prop in props
infos.push "[#{header.name}: #{header.value}]" for header in resource.headers
@log infos.join(", "), "verbose"
verbose: true # we want to see the log printed out to the console
logLevel: "verbose" # of course we want to see logs to our new level :)
###
Every time a resource is received, a new log entry is added to the stack
at the 'verbose' level.
###
casper.on 'resource.received', (resource) ->
infos = []
props = [
"url"
"status"
"statusText"
"redirectURL"
"bodySize"
]
infos.push resource[prop] for prop in props
infos.push "[#{header.name}: #{header.value}]" for header in resource.headers
@log infos.join(", "), "verbose"
# add a new 'verbose' logging level at the lowest priority
casper.logLevels = ["verbose"].concat casper.logLevels
......
......@@ -5,37 +5,33 @@
* A basic custom logging implementation. The idea is to (extremely) verbosely
* log every received resource.
*/
var casper = require("casper").create({
/*
Every time a resource is received, a new log entry is added to the stack at
the 'verbose' level.
*/
onResourceReceived: function(self, resource) {
var header, infos, prop, props, _i, _j, _len, _len1, _ref;
infos = [];
props = [
"url",
"status",
"statusText",
"redirectURL",
"bodySize"
];
for (_i = 0, _len = props.length; _i < _len; _i++) {
prop = props[_i];
infos.push(resource[prop]);
}
_ref = resource.headers;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
header = _ref[_j];
infos.push("[" + header.name + ": " + header.value + "]");
}
this.log(infos.join(", "), "verbose");
},
verbose: true,
logLevel: "verbose"
});
/**
* Every time a resource is received, a new log entry is added to the stack at
* the 'verbose' level.
*/
casper.on('resource.received', function(resource) {
var infos = [];
var props = [
"url",
"status",
"statusText",
"redirectURL",
"bodySize"
];
props.forEach(function(prop) {
infos.push(resource[prop]);
});
resource.headers.forEach(function(header) {
infos.push("[" + header.name + ": " + header.value + "]");
});
this.log(infos.join(", "), "verbose");
});
// add a new 'verbose' logging level at the lowest priority
casper.logLevels = ["verbose"].concat(casper.logLevels);
......
......@@ -14,7 +14,7 @@ casper = require("casper").create verbose: true
casper.fetchScore = ->
@evaluate ->
result = document.querySelector('#resultStats').innerText
result = __utils__.findOne('#resultStats').innerText
parseInt /Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, '')
terms = casper.cli.args # terms are passed through command-line arguments
......
......@@ -19,7 +19,7 @@ var casper = require("casper").create({
casper.fetchScore = function() {
return this.evaluate(function() {
var result = document.querySelector('#resultStats').innerText;
var result = __utils__.findOne('#resultStats').innerText;
return parseInt(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''), 10);
});
};
......