Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
45b095ec
...
45b095ece3b78cd00afe81c5a76e042fcbdeb354
authored
2012-01-17 10:22:59 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated bbcshots sample
1 parent
0cb6c2bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
samples/bbcshots.coffee
samples/bbcshots.js
samples/bbcshots.coffee
View file @
45b095e
...
...
@@ -5,14 +5,18 @@ nbLinks = 0
currentLink
=
1
images
=
[]
casper
.
hide
=
(
selector
)
->
@
evaluate
(
selector
)
->
document
.
querySelector
(
selector
).
style
.
display
=
"none"
,
selector
:
selector
casper
.
start
'http://www.bbc.co.uk/'
,
->
nbLinks
=
@
evaluate
->
return
__utils__
.
findAll
(
'#carousel_items_items li'
).
length
@
echo
"
#{
nbLinks
}
items founds"
# hide navigation arrows
@
evaluate
->
document
.
querySelector
(
'.nav_left'
).
style
.
display
=
"none"
document
.
querySelector
(
'.nav_right'
).
style
.
display
=
"none"
@
hide
'.nav_left'
@
hide
'.nav_right'
@
mouse
.
move
'#promo_carousel'
@
waitUntilVisible
'.autoplay.nav_pause'
,
->
@
echo
'Moving over pause button'
...
...
@@ -22,8 +26,7 @@ casper.start 'http://www.bbc.co.uk/', ->
@
waitUntilVisible
'.autoplay.nav_play'
,
->
@
echo
'Carousel has been paused'
# hide play button
@
evaluate
->
document
.
querySelector
(
'.autoplay'
).
style
.
display
=
"none"
@
hide
'.autoplay'
# Building resulting page and image
buildPage
=
->
...
...
samples/bbcshots.js
View file @
45b095e
...
...
@@ -7,16 +7,21 @@ var casper = require('casper').create(),
currentLink
=
1
,
images
=
[];
// helper to hide some element from remote DOM
casper
.
hide
=
function
(
selector
)
{
this
.
evaluate
(
function
(
selector
)
{
document
.
querySelector
(
selector
).
style
.
display
=
"none"
;
},
{
selector
:
selector
});
};
casper
.
start
(
'http://www.bbc.co.uk/'
,
function
()
{
nbLinks
=
this
.
evaluate
(
function
()
{
return
__utils__
.
findAll
(
'#carousel_items_items li'
).
length
;
});
this
.
echo
(
nbLinks
+
' items founds'
);
// hide navigation arrows
this
.
evaluate
(
function
()
{
document
.
querySelector
(
'.nav_left'
).
style
.
display
=
"none"
;
document
.
querySelector
(
'.nav_right'
).
style
.
display
=
"none"
;
});
this
.
hide
(
'.nav_left'
);
this
.
hide
(
'.nav_right'
);
this
.
mouse
.
move
(
'#promo_carousel'
);
this
.
waitUntilVisible
(
'.autoplay.nav_pause'
,
function
()
{
this
.
echo
(
'Moving over pause button'
);
...
...
@@ -26,9 +31,7 @@ casper.start('http://www.bbc.co.uk/', function() {
this
.
waitUntilVisible
(
'.autoplay.nav_play'
,
function
()
{
this
.
echo
(
'Carousel has been paused'
);
// hide play button
this
.
evaluate
(
function
()
{
document
.
querySelector
(
'.autoplay'
).
style
.
display
=
"none"
;
});
this
.
hide
(
'.autoplay'
);
});
});
});
...
...
Please
register
or
sign in
to post a comment