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
100f22a7
...
100f22a78859b753990927fd95e3f45d14ba69f0
authored
2011-12-21 15:22:06 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added multirun.js code sample
1 parent
04416167
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
samples/multirun.js
samples/multirun.js
0 → 100644
View file @
100f22a
var
casper
=
new
phantom
.
Casper
({
verbose
:
true
});
function
countLinks
()
{
return
document
.
querySelectorAll
(
'a'
).
length
;
}
var
suites
=
[
function
(
self
)
{
self
.
echo
(
'Suite 1'
);
self
.
start
(
'http://google.com/'
,
function
(
self
)
{
self
.
echo
(
'Page title: '
+
self
.
getTitle
());
}).
then
(
function
(
self
)
{
self
.
echo
(
self
.
evaluate
(
countLinks
)
+
' links'
);
});
},
function
(
self
)
{
self
.
echo
(
'Suite 2'
);
self
.
start
(
'http://yahoo.com/'
,
function
(
self
)
{
self
.
echo
(
'Page title: '
+
self
.
getTitle
());
}).
then
(
function
(
self
)
{
self
.
echo
(
self
.
evaluate
(
countLinks
)
+
' links'
);
});
},
function
(
self
)
{
self
.
echo
(
'Suite 3'
);
self
.
start
(
'http://bing.com/'
,
function
(
self
)
{
self
.
echo
(
'Page title: '
+
self
.
getTitle
());
}).
then
(
function
(
self
)
{
self
.
echo
(
self
.
evaluate
(
countLinks
)
+
' links'
);
});
}
];
casper
.
start
().
then
(
function
(
self
)
{
self
.
echo
(
'Starting'
);
});
var
currentSuite
=
0
;
function
check
(
self
)
{
if
(
suites
[
currentSuite
])
{
suites
[
currentSuite
](
casper
);
currentSuite
++
;
casper
.
run
(
check
);
}
else
{
self
.
echo
(
'All done.'
).
exit
();
}
}
casper
.
run
(
check
);
Please
register
or
sign in
to post a comment