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
6165c26b
...
6165c26be03b58f0addf54429f9f5d96ff74172f
authored
2012-01-02 20:11:18 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added events sample
1 parent
0d0e9621
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
1 deletions
modules/casper.js
samples/events.coffee
samples/events.js
modules/casper.js
View file @
6165c26
...
...
@@ -814,7 +814,7 @@ Casper.prototype.start = function(location, then) {
}
},
this
.
options
.
timeout
,
this
);
}
casper
.
emit
(
'casper.page.initialized'
);
this
.
emit
(
'casper.page.initialized'
);
if
(
utils
.
isFunction
(
this
.
options
.
onPageInitialized
))
{
this
.
log
(
"Post-configuring WebPage instance"
,
"debug"
);
this
.
options
.
onPageInitialized
.
call
(
this
,
this
.
page
);
...
...
samples/events.coffee
0 → 100644
View file @
6165c26
casper
=
require
(
'casper'
).
create
()
casper
.
on
"casper.http.status.200"
,
(
resource
)
->
casper
.
echo
"
#{
resource
.
url
}
is OK"
,
"INFO"
casper
.
on
"casper.http.status.301"
,
(
resource
)
->
casper
.
echo
"
#{
resource
.
url
}
is permanently redirected"
,
"PARAMETER"
casper
.
on
"casper.http.status.302"
,
(
resource
)
->
casper
.
echo
"
#{
resource
.
url
}
is temporarily redirected"
,
"PARAMETER"
casper
.
on
"casper.http.status.404"
,
(
resource
)
->
casper
.
echo
"
#{
resource
.
url
}
is not found"
,
"COMMENT"
casper
.
on
"casper.http.status.500"
,
(
resource
)
->
casper
.
echo
"
#{
resource
.
url
}
is in error"
,
"ERROR"
links
=
[
'http://google.com/'
'http://www.google.com/'
'http://www.google.com/plop'
]
casper
.
start
()
for
link
in
links
casper
.
thenOpen
link
,
->
@
echo
"
#{
link
}
loaded"
casper
.
run
()
samples/events.js
0 → 100644
View file @
6165c26
/**
* This script will add a custom HTTP status code handler, here for 404 pages.
*
*/
var
casper
=
require
(
'casper'
).
create
();
casper
.
on
(
'casper.http.status.200'
,
function
(
resource
)
{
casper
.
echo
(
resource
.
url
+
' is OK'
,
'INFO'
);
});
casper
.
on
(
'casper.http.status.301'
,
function
(
resource
)
{
casper
.
echo
(
resource
.
url
+
' is permanently redirected'
,
'PARAMETER'
);
});
casper
.
on
(
'casper.http.status.302'
,
function
(
resource
)
{
casper
.
echo
(
resource
.
url
+
' is temporarily redirected'
,
'PARAMETER'
);
});
casper
.
on
(
'casper.http.status.404'
,
function
(
resource
)
{
casper
.
echo
(
resource
.
url
+
' is not found'
,
'COMMENT'
);
});
casper
.
on
(
'casper.http.status.500'
,
function
(
resource
)
{
casper
.
echo
(
resource
.
url
+
' is in error'
,
'ERROR'
);
});
var
links
=
[
'http://google.com/'
,
'http://www.google.com/'
,
'http://www.google.com/plop'
];
casper
.
start
().
each
(
links
,
function
(
self
,
link
)
{
self
.
thenOpen
(
link
,
function
()
{
this
.
echo
(
link
+
' loaded'
);
});
});
casper
.
run
();
Please
register
or
sign in
to post a comment