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
0c4095fb
...
0c4095fbe02780ed2f13149cad258c9154293057
authored
2011-12-18 14:27:21 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated all samples to use the cli executable
1 parent
1b7e6c85
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
73 additions
and
26 deletions
samples/customlogging.js
samples/download.js
samples/each.js
samples/extends.js
samples/googlelinks.js
samples/googlematch.js
samples/googlepagination.coffee
samples/googletesting.js
samples/logcolor.js
samples/screenshot.js
samples/statushandlers.js
samples/steptimeout.js
samples/timeout.js
samples/customlogging.js
View file @
0c4095f
...
...
@@ -3,7 +3,11 @@
* log every received resource.
*
*/
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
casper
=
new
phantom
.
Casper
({
/**
...
...
samples/download.js
View file @
0c4095f
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
logo
;
...
...
samples/each.js
View file @
0c4095f
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
links
=
[
'http://google.com/'
,
...
...
samples/extends.js
View file @
0c4095f
phantom
.
injectJs
(
"casper.js"
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
articles
=
[];
...
...
samples/googlelinks.js
View file @
0c4095f
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
links
=
[];
var
casper
=
new
phantom
.
Casper
();
...
...
samples/googlematch.js
View file @
0c4095f
...
...
@@ -9,6 +9,12 @@
* borris: 2370000
* winner is "nicolas" with 69600000 results
*/
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
phantom
.
Casper
.
extend
({
fetchScore
:
function
()
{
return
this
.
evaluate
(
function
()
{
...
...
samples/googlepagination.coffee
View file @
0c4095f
...
...
@@ -4,7 +4,9 @@
#
# (all arguments will be used as the query)
#
phantom
.
injectJs
(
'casper.js'
)
if
not
phantom
.
casperLoaded
console
.
log
"This script is intended to work with CasperJS, using its executable."
phantom
.
exit
1
links
=
[]
casper
=
new
phantom
.
Casper
...
...
samples/googletesting.js
View file @
0c4095f
phantom
.
injectJs
(
"casper.js"
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
casper
=
new
phantom
.
Casper
({
logLevel
:
"debug"
...
...
samples/logcolor.js
View file @
0c4095f
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
casper
=
new
phantom
.
Casper
({
verbose
:
true
,
logLevel
:
'debug'
})
});
casper
.
log
(
'this is a debug message'
,
'debug'
);
casper
.
log
(
'and an informative one'
,
'info'
);
casper
.
log
(
'and a warning'
,
'warning'
);
...
...
samples/screenshot.js
View file @
0c4095f
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
casper
=
new
phantom
.
Casper
({
logLevel
:
"debug"
,
...
...
samples/statushandlers.js
View file @
0c4095f
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
var
links
=
[];
var
casper
=
new
phantom
.
Casper
({
...
...
samples/steptimeout.js
View file @
0c4095f
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
if
(
phantom
.
args
.
length
===
0
)
{
console
.
log
(
'You must provide a timeout value'
)
if
(
phantom
.
casperArgs
.
args
.
length
===
0
)
{
console
.
log
(
'You must provide a timeout value'
)
;
phantom
.
exit
(
1
);
}
else
{
var
timeout
=
Number
(
phantom
.
args
[
0
],
10
);
if
(
timeout
<
1
)
{
console
.
log
(
'A timeout value must be a positive integer'
)
}
var
timeout
=
Number
(
phantom
.
casperArgs
.
args
[
0
],
10
);
if
(
timeout
<
1
)
{
console
.
log
(
'A timeout value must be a positive integer'
);
phantom
.
exit
(
1
);
}
}
var
casper
=
new
phantom
.
Casper
({
// verbose: true,
// logLevel: "debug",
stepTimeout
:
timeout
,
onStepTimeout
:
function
(
self
)
{
self
.
echo
(
self
.
requestUrl
+
' failed to load in less than '
+
timeout
+
'ms'
,
'ERROR'
);
...
...
@@ -27,13 +29,17 @@ var links = [
'http://cdiscount.fr/'
];
casper
.
echo
(
'Testing with timeout='
+
timeout
);
casper
.
start
();
casper
.
each
(
links
,
function
(
self
,
link
,
i
)
{
self
.
test
.
comment
(
'Adding '
+
link
+
' to test suite'
);
self
.
thenOpen
(
link
,
function
(
self
)
{
self
.
echo
(
self
.
requestUrl
+
' loaded'
);
});
});
casper
.
run
(
function
(
self
)
{
self
.
test
.
renderResults
(
true
);
self
.
exit
();
...
...
samples/timeout.js
View file @
0c4095f
...
...
@@ -14,15 +14,18 @@
* Will google.com load in less than 2000ms?
* YES!
*/
phantom
.
injectJs
(
'casper.js'
);
if
(
!
phantom
.
casperLoaded
)
{
console
.
log
(
'This script is intended to work with CasperJS, using its executable.'
);
phantom
.
exit
(
1
);
}
if
(
phantom
.
args
.
length
===
0
)
{
console
.
log
(
'You must provide a timeout value'
)
if
(
phantom
.
casperArgs
.
args
.
length
===
0
)
{
console
.
log
(
'You must provide a timeout value'
)
;
phantom
.
exit
(
1
);
}
else
{
var
timeout
=
Number
(
phantom
.
args
[
0
],
10
);
var
timeout
=
Number
(
phantom
.
casperArgs
.
args
[
0
],
10
);
if
(
timeout
<
1
)
{
console
.
log
(
'A timeout value must be a positive integer'
)
console
.
log
(
'A timeout value must be a positive integer'
)
;
phantom
.
exit
(
1
);
}
}
...
...
Please
register
or
sign in
to post a comment