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
e429daff
...
e429daff0eb9f99544e998cc329e03bd84bb31dd
authored
2011-12-08 23:48:21 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
closes #24 - added custom logging example
1 parent
f7787f50
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
samples/customlogging.js
samples/each.js
samples/googlelinks.js
tests/run.js
samples/customlogging.js
0 → 100644
View file @
e429daf
phantom
.
injectJs
(
'casper.js'
);
var
casper
=
new
phantom
.
Casper
({
onResourceReceived
:
function
(
self
,
resource
)
{
var
infos
=
[
resource
.
url
,
resource
.
status
,
resource
.
statusText
,
resource
.
redirectURL
,
resource
.
bodySize
];
resource
.
headers
.
forEach
(
function
(
header
)
{
infos
.
push
(
'['
+
[
header
.
name
,
header
.
value
].
join
(
', '
)
+
']'
);
});
self
.
log
(
infos
.
join
(
', '
),
'verbose'
);
},
verbose
:
true
,
logLevel
:
'verbose'
});
casper
.
logLevels
=
[
'verbose'
].
concat
(
casper
.
logLevels
);
casper
.
start
(
'http://www.google.com/'
).
run
(
function
(
self
)
{
self
.
exit
();
});
samples/each.js
View file @
e429daf
...
...
@@ -6,8 +6,6 @@ var links = [
'http://bing.com/'
];
var
casper
=
new
phantom
.
Casper
();
var
i
=
0
;
var
titles
=
[];
casper
.
start
();
...
...
samples/googlelinks.js
View file @
e429daf
...
...
@@ -6,7 +6,7 @@ var casper = new phantom.Casper();
function
getLinks
()
{
var
links
=
document
.
querySelectorAll
(
'h3.r a'
);
return
Array
.
prototype
.
map
.
call
(
links
,
function
(
e
)
{
return
e
.
getAttribute
(
'href'
)
return
e
.
getAttribute
(
'href'
)
;
});
}
...
...
tests/run.js
View file @
e429daf
...
...
@@ -47,7 +47,7 @@ casper.start('tests/site/index.html', function(self) {
self
.
click
(
'a[href="test.html"]'
);
});
casper
.
test
.
assert
(
casper
.
steps
.
length
===
1
,
'Casper.start() can add a new navigation step'
);
casper
.
test
.
assert
Equals
(
casper
.
steps
.
length
,
2
,
'Casper.start() can add a new navigation step'
);
// Casper.viewport()
casper
.
test
.
comment
(
'viewport'
);
...
...
@@ -63,7 +63,7 @@ casper.then(function(self) {
self
.
click
(
'a[href="form.html"]'
);
});
casper
.
test
.
assert
(
casper
.
steps
.
length
===
2
,
'Casper.then() adds a new navigation step'
);
casper
.
test
.
assert
(
casper
.
steps
.
length
===
3
,
'Casper.then() adds a new navigation step'
);
// Casper#capture()
casper
.
test
.
comment
(
'capturing'
);
...
...
Please
register
or
sign in
to post a comment