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
161d32ac
...
161d32ac24e850396d589be9057c32db0f5dae66
authored
2012-06-24 13:51:35 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed tests for phantomjs < 1.6
1 parent
9697410d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
docs
modules/casper.js
tests/suites/casper/capture.js
docs
@
8ef6a7b3
Subproject commit
dd54a24e01c379ad5b34dfb2ec11323a95a7e25f
Subproject commit
8ef6a7b312c799466acf3691de0a59d7f48a4c29
...
...
modules/casper.js
View file @
161d32a
...
...
@@ -221,6 +221,9 @@ Casper.prototype.base64encode = function base64encode(url, method, data) {
*/
Casper
.
prototype
.
capture
=
function
capture
(
targetFile
,
clipRect
)
{
"use strict"
;
if
(
!
this
.
started
)
{
throw
new
CasperError
(
"Casper not started, can't capture()"
);
}
var
previousClipRect
;
targetFile
=
fs
.
absolute
(
targetFile
);
if
(
clipRect
)
{
...
...
@@ -258,6 +261,13 @@ Casper.prototype.capture = function capture(targetFile, clipRect) {
*/
Casper
.
prototype
.
captureBase64
=
function
captureBase64
(
format
,
area
)
{
"use strict"
;
if
(
!
this
.
started
)
{
throw
new
CasperError
(
"Casper not started, can't captureBase64()"
);
}
if
(
!
(
'renderBase64'
in
this
.
page
))
{
this
.
warn
(
'captureBase64() requires PhantomJS >= 1.6'
);
return
;
}
var
base64
;
var
previousClipRect
;
var
formats
=
[
'bmp'
,
'jpg'
,
'jpeg'
,
'png'
,
'ppm'
,
'tiff'
,
'xbm'
,
'xpm'
];
...
...
tests/suites/casper/capture.js
View file @
161d32a
...
...
@@ -11,7 +11,8 @@ casper.start('tests/site/index.html', function() {
this
.
test
.
assert
(
fs
.
isFile
(
testFile
),
'Casper.capture() captured a screenshot'
);
});
casper
.
thenOpen
(
'tests/site/index.html'
,
function
()
{
if
(
phantom
.
version
.
major
===
1
&&
phantom
.
version
.
minor
>=
6
)
{
casper
.
thenOpen
(
'tests/site/index.html'
,
function
()
{
this
.
test
.
comment
(
'Casper.captureBase64()'
);
this
.
test
.
assert
(
this
.
captureBase64
(
'png'
).
length
>
0
,
'Casper.captureBase64() rendered a page capture as base64'
);
...
...
@@ -19,7 +20,8 @@ casper.thenOpen('tests/site/index.html', function() {
'Casper.captureBase64() rendered a capture from a selector as base64'
);
this
.
test
.
assert
(
this
.
captureBase64
(
'png'
,
{
top
:
0
,
left
:
0
,
width
:
30
,
height
:
30
}).
length
>
0
,
'Casper.captureBase64() rendered a capture from a clipRect as base64'
);
});
});
}
casper
.
run
(
function
()
{
try
{
...
...
Please
register
or
sign in
to post a comment