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
93678e97
...
93678e9797e342fd470ad25bf2cc4269e97941ac
authored
2011-11-25 12:40:11 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added Casper.options.onStepComplete() callback
1 parent
a56aadfe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
casper.js
tests/run.js
casper.js
View file @
93678e9
...
...
@@ -49,6 +49,7 @@
onError
:
null
,
onLoadError
:
null
,
onPageInitialized
:
null
,
onStepComplete
:
null
,
onStepTimeout
:
null
,
onTimeout
:
null
,
page
:
null
,
...
...
@@ -612,6 +613,7 @@
runStep
:
function
(
step
)
{
var
skipLog
=
isType
(
step
.
options
,
"object"
)
&&
step
.
options
.
skipLog
===
true
;
var
stepInfo
=
"Step "
+
(
this
.
step
+
1
)
+
"/"
+
this
.
steps
.
length
;
var
stepResult
;
if
(
!
skipLog
)
{
this
.
log
(
stepInfo
+
' '
+
this
.
getCurrentUrl
()
+
' (HTTP '
+
this
.
currentHTTPStatus
+
')'
,
"info"
);
}
...
...
@@ -630,7 +632,7 @@
},
this
.
options
.
stepTimeout
,
this
,
new
Date
().
getTime
(),
this
.
step
);
}
try
{
step
(
this
);
step
Result
=
step
(
this
);
}
catch
(
e
)
{
if
(
this
.
options
.
faultTolerant
)
{
this
.
log
(
"Step error: "
+
e
,
"error"
);
...
...
@@ -638,6 +640,9 @@
throw
e
;
}
}
if
(
isType
(
this
.
options
.
onStepComplete
,
"function"
))
{
this
.
options
.
onStepComplete
(
this
,
stepResult
);
}
if
(
!
skipLog
)
{
this
.
log
(
stepInfo
+
": done in "
+
(
new
Date
().
getTime
()
-
this
.
startTime
)
+
"ms."
,
"info"
);
}
...
...
tests/run.js
View file @
93678e9
...
...
@@ -213,6 +213,15 @@ casper.thenOpen('tests/site/global.html', function(self) {
self
.
test
.
assertEquals
(
self
.
getGlobal
(
'myGlobal'
),
'awesome string'
,
'global retrieved'
)
});
// Casper.options.onStepComplete
casper
.
then
(
function
(
self
)
{
self
.
options
.
onStepComplete
=
function
(
self
,
stepResult
)
{
self
.
test
.
assertEquals
(
stepResult
,
'ok'
,
'Casper.options.onStepComplete() is called on step complete'
);
self
.
options
.
onStepComplete
=
null
;
};
return
'ok'
;
});
// History
casper
.
thenOpen
(
'tests/site/page1.html'
)
...
...
Please
register
or
sign in
to post a comment