updated bbcshots sample
Showing
2 changed files
with
18 additions
and
12 deletions
... | @@ -5,14 +5,18 @@ nbLinks = 0 | ... | @@ -5,14 +5,18 @@ nbLinks = 0 |
5 | currentLink = 1 | 5 | currentLink = 1 |
6 | images = [] | 6 | images = [] |
7 | 7 | ||
8 | casper.hide = (selector) -> | ||
9 | @evaluate (selector) -> | ||
10 | document.querySelector(selector).style.display = "none" | ||
11 | , selector: selector | ||
12 | |||
8 | casper.start 'http://www.bbc.co.uk/', -> | 13 | casper.start 'http://www.bbc.co.uk/', -> |
9 | nbLinks = @evaluate -> | 14 | nbLinks = @evaluate -> |
10 | return __utils__.findAll('#carousel_items_items li').length | 15 | return __utils__.findAll('#carousel_items_items li').length |
11 | @echo "#{nbLinks} items founds" | 16 | @echo "#{nbLinks} items founds" |
12 | # hide navigation arrows | 17 | # hide navigation arrows |
13 | @evaluate -> | 18 | @hide '.nav_left' |
14 | document.querySelector('.nav_left').style.display = "none" | 19 | @hide '.nav_right' |
15 | document.querySelector('.nav_right').style.display = "none" | ||
16 | @mouse.move '#promo_carousel' | 20 | @mouse.move '#promo_carousel' |
17 | @waitUntilVisible '.autoplay.nav_pause', -> | 21 | @waitUntilVisible '.autoplay.nav_pause', -> |
18 | @echo 'Moving over pause button' | 22 | @echo 'Moving over pause button' |
... | @@ -22,8 +26,7 @@ casper.start 'http://www.bbc.co.uk/', -> | ... | @@ -22,8 +26,7 @@ casper.start 'http://www.bbc.co.uk/', -> |
22 | @waitUntilVisible '.autoplay.nav_play', -> | 26 | @waitUntilVisible '.autoplay.nav_play', -> |
23 | @echo 'Carousel has been paused' | 27 | @echo 'Carousel has been paused' |
24 | # hide play button | 28 | # hide play button |
25 | @evaluate -> | 29 | @hide '.autoplay' |
26 | document.querySelector('.autoplay').style.display = "none" | ||
27 | 30 | ||
28 | # Building resulting page and image | 31 | # Building resulting page and image |
29 | buildPage = -> | 32 | buildPage = -> | ... | ... |
... | @@ -7,16 +7,21 @@ var casper = require('casper').create(), | ... | @@ -7,16 +7,21 @@ var casper = require('casper').create(), |
7 | currentLink = 1, | 7 | currentLink = 1, |
8 | images = []; | 8 | images = []; |
9 | 9 | ||
10 | // helper to hide some element from remote DOM | ||
11 | casper.hide = function(selector) { | ||
12 | this.evaluate(function(selector) { | ||
13 | document.querySelector(selector).style.display = "none"; | ||
14 | }, { selector: selector }); | ||
15 | }; | ||
16 | |||
10 | casper.start('http://www.bbc.co.uk/', function() { | 17 | casper.start('http://www.bbc.co.uk/', function() { |
11 | nbLinks = this.evaluate(function() { | 18 | nbLinks = this.evaluate(function() { |
12 | return __utils__.findAll('#carousel_items_items li').length; | 19 | return __utils__.findAll('#carousel_items_items li').length; |
13 | }); | 20 | }); |
14 | this.echo(nbLinks + ' items founds'); | 21 | this.echo(nbLinks + ' items founds'); |
15 | // hide navigation arrows | 22 | // hide navigation arrows |
16 | this.evaluate(function() { | 23 | this.hide('.nav_left'); |
17 | document.querySelector('.nav_left').style.display = "none"; | 24 | this.hide('.nav_right'); |
18 | document.querySelector('.nav_right').style.display = "none"; | ||
19 | }); | ||
20 | this.mouse.move('#promo_carousel'); | 25 | this.mouse.move('#promo_carousel'); |
21 | this.waitUntilVisible('.autoplay.nav_pause', function() { | 26 | this.waitUntilVisible('.autoplay.nav_pause', function() { |
22 | this.echo('Moving over pause button'); | 27 | this.echo('Moving over pause button'); |
... | @@ -26,9 +31,7 @@ casper.start('http://www.bbc.co.uk/', function() { | ... | @@ -26,9 +31,7 @@ casper.start('http://www.bbc.co.uk/', function() { |
26 | this.waitUntilVisible('.autoplay.nav_play', function() { | 31 | this.waitUntilVisible('.autoplay.nav_play', function() { |
27 | this.echo('Carousel has been paused'); | 32 | this.echo('Carousel has been paused'); |
28 | // hide play button | 33 | // hide play button |
29 | this.evaluate(function() { | 34 | this.hide('.autoplay'); |
30 | document.querySelector('.autoplay').style.display = "none"; | ||
31 | }); | ||
32 | }); | 35 | }); |
33 | }); | 36 | }); |
34 | }); | 37 | }); | ... | ... |
-
Please register or sign in to post a comment