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
86217d8d
...
86217d8da1eaeeb7c19277a3b5c34295b9e73d44
authored
2011-10-01 11:48:56 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added an 'onError' Casper setting
1 parent
5b590280
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
README.md
casper.js
README.md
View file @
86217d8
...
...
@@ -222,13 +222,17 @@ phantom.injectJs('path/to/casper.js');
var
casper
=
new
phantom
.
Casper
({
clientScripts
:
[
'includes/jquery.js'
,
'includes/underscore.js'
'includes/jquery.js'
,
// These two scripts will be injected in remote
'includes/underscore.js'
// DOM on every request
],
logLevel
:
"info"
,
logLevel
:
"info"
,
// Only "info" level messages will be logged
onError
:
function
(
self
,
m
)
{
// Any "error" level message will be written
console
.
log
(
'FATAL:'
+
m
);
// on the console output and PhantomJS will
self
.
exit
();
// terminate
},
pageSettings
:
{
loadImages
:
false
,
loadPlugins
:
false
loadImages
:
false
,
// The WebPage instance used by Casper will
loadPlugins
:
false
// use these settings
}
});
```
...
...
casper.js
View file @
86217d8
...
...
@@ -31,6 +31,7 @@
* clientScripts | Array | [] | A collection of script filepaths to include to every page loaded
* logLevel | String | "error" | Logging level (see logLevels for available values)
* onDie | function | null | A function to be called when Casper#die() is called
* onError | function | null | A function to be called when an "error" level event occurs
* onPageInitialized | function | null | A function to be called after WebPage instance has been initialized
* page | WebPage | null | An existing WebPage instance
* pageSettings | Object | {} | PhantomJS's WebPage settings object
...
...
@@ -51,6 +52,7 @@
clientScripts
:
[],
logLevel
:
"error"
,
onDie
:
null
,
onError
:
null
,
onPageInitialized
:
null
,
page
:
null
,
pageSettings
:
{
userAgent
:
DEFAULT_USER_AGENT
},
...
...
@@ -286,6 +288,9 @@
log
:
function
(
message
,
level
,
space
)
{
level
=
level
&&
this
.
logLevels
.
indexOf
(
level
)
>
-
1
?
level
:
"debug"
;
space
=
space
?
space
:
"phantom"
;
if
(
level
===
"error"
&&
typeof
(
this
.
options
.
onError
)
===
"function"
)
{
this
.
options
.
onError
(
this
,
message
,
space
);
}
if
(
this
.
logLevels
.
indexOf
(
level
)
<
this
.
logLevels
.
indexOf
(
this
.
options
.
logLevel
))
{
return
this
;
// skip logging
}
...
...
Please
register
or
sign in
to post a comment