Commit 0cef17ee 0cef17eea509dd23ee8e70ba53fd97bca427672f by Nicolas Perriault

fixes #325

1 parent 19d0f4c2
......@@ -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 = ->
......
......@@ -28,16 +28,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);
});
};
......