Commit 0cef17ee 0cef17eea509dd23ee8e70ba53fd97bca427672f by Nicolas Perriault

fixes #325

1 parent 19d0f4c2
......@@ -21,7 +21,8 @@ casper.start "http://www.bbc.co.uk/", ->
@hide ".nav_left"
@hide ".nav_right"
@mouse.move "#promo2_carousel"
@waitUntilVisible ".autoplay.nav_pause", ->
casper.waitUntilVisible ".autoplay.nav_pause", ->
@echo "Moving over pause button"
@mouse.move ".autoplay.nav_pause"
@click ".autoplay.nav_pause"
......
......@@ -28,7 +28,9 @@ 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() {
});
casper.waitUntilVisible(".autoplay.nav_pause", function() {
this.echo("Moving over pause button");
this.mouse.move(".autoplay.nav_pause");
this.click(".autoplay.nav_pause");
......@@ -38,7 +40,6 @@ casper.start("http://www.bbc.co.uk/", function() {
// hide play button
this.hide(".autoplay");
});
});
});
// Capture carrousel area
......
......@@ -2,15 +2,15 @@
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.
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 :)
@param Object resource A phantomjs resource object
###
onResourceReceived: (self, resource) ->
###
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"
......@@ -22,8 +22,6 @@ casper = require("casper").create
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 :)
# add a new 'verbose' logging level at the lowest priority
casper.logLevels = ["verbose"].concat casper.logLevels
......
......@@ -5,35 +5,31 @@
* 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.
verbose: true,
logLevel: "verbose"
});
/**
* 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 = [
casper.on('resource.received', function(resource) {
var infos = [];
var props = [
"url",
"status",
"statusText",
"redirectURL",
"bodySize"
];
for (_i = 0, _len = props.length; _i < _len; _i++) {
prop = props[_i];
props.forEach(function(prop) {
infos.push(resource[prop]);
}
_ref = resource.headers;
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
header = _ref[_j];
});
resource.headers.forEach(function(header) {
infos.push("[" + header.name + ": " + header.value + "]");
}
});
this.log(infos.join(", "), "verbose");
},
verbose: true,
logLevel: "verbose"
});
// add a new 'verbose' logging level at the lowest priority
......
......@@ -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);
});
};
......