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
34d6e3f7
...
34d6e3f783a5586fa5d3727ebd1137973b51e432
authored
2012-06-04 14:49:23 +0200
by
Brikou CARRE
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
reverted inline comments
1 parent
63ba92bb
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
22 deletions
samples/bbcshots.coffee
samples/bbcshots.js
samples/cliplay.coffee
samples/cliplay.js
samples/customlogging.js
samples/dynamic.coffee
samples/dynamic.js
samples/logcolor.js
samples/bbcshots.coffee
View file @
34d6e3f
...
...
@@ -7,7 +7,7 @@ nbLinks = 0
currentLink
=
1
images
=
[]
#
## helper to hide some element from remote DOM ###
#
helper to hide some element from remote DOM
casper
.
hide
=
(
selector
)
->
@
evaluate
(
selector
)
->
document
.
querySelector
(
selector
).
style
.
display
=
"none"
...
...
@@ -17,7 +17,7 @@ casper.start "http://www.bbc.co.uk/", ->
nbLinks
=
@
evaluate
->
return
__utils__
.
findAll
(
'#promo2_carousel_items_items li'
).
length
@
echo
"
#{
nbLinks
}
items founds"
#
## hide navigation arrows ###
#
hide navigation arrows
@
hide
".nav_left"
@
hide
".nav_right"
@
mouse
.
move
"#promo2_carousel"
...
...
@@ -28,10 +28,10 @@ casper.start "http://www.bbc.co.uk/", ->
@
echo
"Clicked on pause button"
@
waitUntilVisible
".autoplay.nav_play"
,
->
@
echo
"Carousel has been paused"
#
## hide play button ###
#
hide play button
@
hide
".autoplay"
#
## Capture carrousel area ###
#
Capture carrousel area
next
=
->
image
=
"bbcshot
#{
currentLink
}
.png"
images
.
push
image
...
...
@@ -45,7 +45,7 @@ next = ->
else
@
then
buildPage
#
## Building resulting page and image ###
#
Building resulting page and image
buildPage
=
->
@
echo
"Build result page"
fs
=
require
"fs"
...
...
samples/bbcshots.js
View file @
34d6e3f
...
...
@@ -9,7 +9,7 @@ nbLinks = 0;
currentLink
=
1
;
images
=
[];
/
* helper to hide some element from remote DOM */
/
/ helper to hide some element from remote DOM
casper
.
hide
=
function
(
selector
)
{
this
.
evaluate
(
function
(
selector
)
{
document
.
querySelector
(
selector
).
style
.
display
=
"none"
;
...
...
@@ -23,7 +23,7 @@ casper.start("http://www.bbc.co.uk/", function() {
return
__utils__
.
findAll
(
'#promo2_carousel_items_items li'
).
length
;
});
this
.
echo
(
nbLinks
+
" items founds"
);
/
* hide navigation arrows */
/
/ hide navigation arrows
this
.
hide
(
".nav_left"
);
this
.
hide
(
".nav_right"
);
this
.
mouse
.
move
(
"#promo2_carousel"
);
...
...
@@ -34,13 +34,13 @@ casper.start("http://www.bbc.co.uk/", function() {
this
.
echo
(
"Clicked on pause button"
);
this
.
waitUntilVisible
(
".autoplay.nav_play"
,
function
()
{
this
.
echo
(
"Carousel has been paused"
);
/
* hide play button */
/
/ hide play button
this
.
hide
(
".autoplay"
);
});
});
});
/
* Capture carrousel area */
/
/ Capture carrousel area
next
=
function
()
{
var
image
;
image
=
"bbcshot"
+
currentLink
+
".png"
;
...
...
@@ -58,7 +58,7 @@ next = function() {
}
};
/
* Building resulting page and image */
/
/ Building resulting page and image
buildPage
=
function
()
{
var
fs
,
pageHtml
;
this
.
echo
(
"Build result page"
);
...
...
samples/cliplay.coffee
View file @
34d6e3f
casper
=
require
(
"casper"
).
create
()
dump
=
require
(
"utils"
).
dump
#
## removing default options passed by the Python executable ###
#
removing default options passed by the Python executable
casper
.
cli
.
drop
"cli"
casper
.
cli
.
drop
"casper-path"
...
...
samples/cliplay.js
View file @
34d6e3f
...
...
@@ -3,7 +3,7 @@ var casper, dump;
casper
=
require
(
"casper"
).
create
();
dump
=
require
(
"utils"
).
dump
;
/
* removing default options passed by the Python executable */
/
/ removing default options passed by the Python executable
casper
.
cli
.
drop
(
"cli"
);
casper
.
cli
.
drop
(
"casper-path"
);
...
...
samples/customlogging.js
View file @
34d6e3f
...
...
@@ -33,7 +33,7 @@ var casper = require("casper").create({
logLevel
:
"verbose"
});
/
* add a new 'verbose' logging level at the lowest priority */
/
/ add a new 'verbose' logging level at the lowest priority
casper
.
logLevels
=
[
"verbose"
].
concat
(
casper
.
logLevels
);
// test our new logger with google
...
...
samples/dynamic.coffee
View file @
34d6e3f
casper
=
require
(
"casper"
).
create
verbose
:
true
#
## If we don't set a limit, it could go on forever ###
#
If we don't set a limit, it could go on forever
upTo
=
~~
casper
.
cli
.
get
(
0
)
||
10
###
...
...
@@ -16,14 +16,14 @@ searchLinks = ->
),
(
a
)
->
a
.
getAttribute
"href"
#
## The base links array ###
#
The base links array
links
=
[
"http://google.com/"
"http://yahoo.com/"
"http://bing.com/"
]
#
## Just opens the page and prints the title ###
#
Just opens the page and prints the title
start
=
(
link
)
->
@
start
link
,
->
@
echo
"Page title:
#{
@
getTitle
()
}
"
...
...
@@ -45,7 +45,7 @@ casper.then ->
currentLink
=
0
;
#
## As long as it has a next link, and is under the maximum limit, will keep running ###
#
As long as it has a next link, and is under the maximum limit, will keep running
check
=
->
if
links
[
currentLink
]
&&
currentLink
<
upTo
@
echo
"--- Link
#{
currentLink
}
---"
...
...
samples/dynamic.js
View file @
34d6e3f
...
...
@@ -4,7 +4,7 @@ casper = require("casper").create({
verbose
:
true
});
/
* If we don't set a limit, it could go on forever */
/
/ If we don't set a limit, it could go on forever
upTo
=
~~
casper
.
cli
.
get
(
0
)
||
10
;
/*
...
...
@@ -22,7 +22,7 @@ searchLinks = function() {
});
};
/
* The base links array */
/
/ The base links array
links
=
[
"http://google.com/"
,
"http://yahoo.com/"
,
...
...
samples/logcolor.js
View file @
34d6e3f
var
casper
;
casper
=
require
(
"casper"
).
create
({
var
casper
=
require
(
"casper"
).
create
({
verbose
:
true
,
logLevel
:
"debug"
});
...
...
Please
register
or
sign in
to post a comment