Commit 0cef17ee 0cef17eea509dd23ee8e70ba53fd97bca427672f by Nicolas Perriault

fixes #325

1 parent 19d0f4c2
...@@ -21,7 +21,8 @@ casper.start "http://www.bbc.co.uk/", -> ...@@ -21,7 +21,8 @@ casper.start "http://www.bbc.co.uk/", ->
21 @hide ".nav_left" 21 @hide ".nav_left"
22 @hide ".nav_right" 22 @hide ".nav_right"
23 @mouse.move "#promo2_carousel" 23 @mouse.move "#promo2_carousel"
24 @waitUntilVisible ".autoplay.nav_pause", -> 24
25 casper.waitUntilVisible ".autoplay.nav_pause", ->
25 @echo "Moving over pause button" 26 @echo "Moving over pause button"
26 @mouse.move ".autoplay.nav_pause" 27 @mouse.move ".autoplay.nav_pause"
27 @click ".autoplay.nav_pause" 28 @click ".autoplay.nav_pause"
......
...@@ -28,7 +28,9 @@ casper.start("http://www.bbc.co.uk/", function() { ...@@ -28,7 +28,9 @@ casper.start("http://www.bbc.co.uk/", function() {
28 this.hide(".nav_left"); 28 this.hide(".nav_left");
29 this.hide(".nav_right"); 29 this.hide(".nav_right");
30 this.mouse.move("#promo2_carousel"); 30 this.mouse.move("#promo2_carousel");
31 this.waitUntilVisible(".autoplay.nav_pause", function() { 31 });
32
33 casper.waitUntilVisible(".autoplay.nav_pause", function() {
32 this.echo("Moving over pause button"); 34 this.echo("Moving over pause button");
33 this.mouse.move(".autoplay.nav_pause"); 35 this.mouse.move(".autoplay.nav_pause");
34 this.click(".autoplay.nav_pause"); 36 this.click(".autoplay.nav_pause");
...@@ -38,7 +40,6 @@ casper.start("http://www.bbc.co.uk/", function() { ...@@ -38,7 +40,6 @@ casper.start("http://www.bbc.co.uk/", function() {
38 // hide play button 40 // hide play button
39 this.hide(".autoplay"); 41 this.hide(".autoplay");
40 }); 42 });
41 });
42 }); 43 });
43 44
44 // Capture carrousel area 45 // Capture carrousel area
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
2 A basic custom logging implementation. The idea is to (extremely) verbosely 2 A basic custom logging implementation. The idea is to (extremely) verbosely
3 log every received resource. 3 log every received resource.
4 ### 4 ###
5
6 casper = require("casper").create 5 casper = require("casper").create
7 ### 6 verbose: true # we want to see the log printed out to the console
8 Every time a resource is received, a new log entry is added to the stack 7 logLevel: "verbose" # of course we want to see logs to our new level :)
9 at the 'verbose' level.
10 8
11 @param Object resource A phantomjs resource object 9 ###
12 ### 10 Every time a resource is received, a new log entry is added to the stack
13 onResourceReceived: (self, resource) -> 11 at the 'verbose' level.
12 ###
13 casper.on 'resource.received', (resource) ->
14 infos = [] 14 infos = []
15 props = [ 15 props = [
16 "url" 16 "url"
...@@ -22,8 +22,6 @@ casper = require("casper").create ...@@ -22,8 +22,6 @@ casper = require("casper").create
22 infos.push resource[prop] for prop in props 22 infos.push resource[prop] for prop in props
23 infos.push "[#{header.name}: #{header.value}]" for header in resource.headers 23 infos.push "[#{header.name}: #{header.value}]" for header in resource.headers
24 @log infos.join(", "), "verbose" 24 @log infos.join(", "), "verbose"
25 verbose: true # we want to see the log printed out to the console
26 logLevel: "verbose" # of course we want to see logs to our new level :)
27 25
28 # add a new 'verbose' logging level at the lowest priority 26 # add a new 'verbose' logging level at the lowest priority
29 casper.logLevels = ["verbose"].concat casper.logLevels 27 casper.logLevels = ["verbose"].concat casper.logLevels
......
...@@ -5,35 +5,31 @@ ...@@ -5,35 +5,31 @@
5 * A basic custom logging implementation. The idea is to (extremely) verbosely 5 * A basic custom logging implementation. The idea is to (extremely) verbosely
6 * log every received resource. 6 * log every received resource.
7 */ 7 */
8
9 var casper = require("casper").create({ 8 var casper = require("casper").create({
10 /* 9 verbose: true,
11 Every time a resource is received, a new log entry is added to the stack at 10 logLevel: "verbose"
12 the 'verbose' level. 11 });
12
13 /**
14 * Every time a resource is received, a new log entry is added to the stack at
15 * the 'verbose' level.
13 */ 16 */
14 onResourceReceived: function(self, resource) { 17 casper.on('resource.received', function(resource) {
15 var header, infos, prop, props, _i, _j, _len, _len1, _ref; 18 var infos = [];
16 infos = []; 19 var props = [
17 props = [
18 "url", 20 "url",
19 "status", 21 "status",
20 "statusText", 22 "statusText",
21 "redirectURL", 23 "redirectURL",
22 "bodySize" 24 "bodySize"
23 ]; 25 ];
24 for (_i = 0, _len = props.length; _i < _len; _i++) { 26 props.forEach(function(prop) {
25 prop = props[_i];
26 infos.push(resource[prop]); 27 infos.push(resource[prop]);
27 } 28 });
28 _ref = resource.headers; 29 resource.headers.forEach(function(header) {
29 for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
30 header = _ref[_j];
31 infos.push("[" + header.name + ": " + header.value + "]"); 30 infos.push("[" + header.name + ": " + header.value + "]");
32 } 31 });
33 this.log(infos.join(", "), "verbose"); 32 this.log(infos.join(", "), "verbose");
34 },
35 verbose: true,
36 logLevel: "verbose"
37 }); 33 });
38 34
39 // add a new 'verbose' logging level at the lowest priority 35 // add a new 'verbose' logging level at the lowest priority
......
...@@ -14,7 +14,7 @@ casper = require("casper").create verbose: true ...@@ -14,7 +14,7 @@ casper = require("casper").create verbose: true
14 14
15 casper.fetchScore = -> 15 casper.fetchScore = ->
16 @evaluate -> 16 @evaluate ->
17 result = document.querySelector('#resultStats').innerText 17 result = __utils__.findOne('#resultStats').innerText
18 parseInt /Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, '') 18 parseInt /Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, '')
19 19
20 terms = casper.cli.args # terms are passed through command-line arguments 20 terms = casper.cli.args # terms are passed through command-line arguments
......
...@@ -19,7 +19,7 @@ var casper = require("casper").create({ ...@@ -19,7 +19,7 @@ var casper = require("casper").create({
19 19
20 casper.fetchScore = function() { 20 casper.fetchScore = function() {
21 return this.evaluate(function() { 21 return this.evaluate(function() {
22 var result = document.querySelector('#resultStats').innerText; 22 var result = __utils__.findOne('#resultStats').innerText;
23 return parseInt(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''), 10); 23 return parseInt(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''), 10);
24 }); 24 });
25 }; 25 };
......