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
9c2102ca
...
9c2102ca0999a153b681f6828d27fd76b07b51d7
authored
2012-01-05 19:51:55 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added moar events
1 parent
aecbfb7d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
modules/casper.js
modules/casper.js
View file @
9c2102c
...
...
@@ -166,10 +166,12 @@ Casper.prototype.capture = function(targetFile, clipRect) {
this
.
page
.
clipRect
=
clipRect
;
this
.
log
(
f
(
"Capturing page to %s with clipRect %s"
,
targetFile
,
JSON
.
stringify
(
clipRect
)),
"debug"
);
}
else
{
this
.
log
(
f
(
'Capturing page to %s'
,
targetFile
),
"debug"
);
this
.
log
(
f
(
"Capturing page to %s"
,
targetFile
),
"debug"
);
}
if
(
!
this
.
page
.
render
(
targetFile
))
{
if
(
!
this
.
page
.
render
(
t
his
.
filter
(
'capture.target_filename'
,
targetFile
)
||
t
argetFile
))
{
this
.
log
(
f
(
"Failed to save screenshot to %s; please check permissions"
,
targetFile
),
"error"
);
}
else
{
this
.
emit
(
'capture.saved'
,
targetFile
);
}
if
(
previousClipRect
)
{
this
.
page
.
clipRect
=
previousClipRect
;
...
...
@@ -310,6 +312,7 @@ Casper.prototype.download = function(url, targetPath) {
var
cu
=
require
(
'clientutils'
).
create
();
try
{
fs
.
write
(
targetPath
,
cu
.
decode
(
this
.
base64encode
(
url
)),
'w'
);
this
.
emit
(
'downloaded.file'
,
targetPath
);
}
catch
(
e
)
{
this
.
log
(
f
(
"Error while downloading %s to %s: %s"
,
url
,
targetPath
,
e
),
"error"
);
}
...
...
@@ -344,7 +347,8 @@ Casper.prototype.each = function(array, fn) {
* @return Casper
*/
Casper
.
prototype
.
echo
=
function
(
text
,
style
)
{
console
.
log
(
style
?
this
.
colorizer
.
colorize
(
text
,
style
)
:
text
);
var
message
=
style
?
this
.
colorizer
.
colorize
(
text
,
style
)
:
text
;
console
.
log
(
this
.
filter
(
'echo.message'
,
message
)
||
message
);
return
this
;
};
...
...
@@ -781,6 +785,7 @@ Casper.prototype.setHttpAuth = function(username, password) {
}
this
.
page
.
settings
.
userName
=
username
;
this
.
page
.
settings
.
password
=
password
;
this
.
emit
(
'http.auth'
,
username
,
password
);
this
.
log
(
"Setting HTTP authentication for user "
+
username
,
"info"
);
return
this
;
};
...
...
@@ -976,8 +981,8 @@ Casper.prototype.viewport = function(width, height) {
* @return Casper
*/
Casper
.
prototype
.
wait
=
function
(
timeout
,
then
)
{
timeout
=
Number
(
timeout
,
10
)
;
if
(
!
utils
.
isNumber
(
timeout
)
||
timeout
<
1
)
{
timeout
=
~~
timeout
;
if
(
timeout
<
1
)
{
this
.
die
(
"wait() only accepts a positive integer > 0 as a timeout value"
);
}
if
(
then
&&
!
utils
.
isFunction
(
then
))
{
...
...
Please
register
or
sign in
to post a comment