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
c132c434
...
c132c434f6ea75559fb419495d3bcc356d022306
authored
2012-12-18 09:21:39 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'rbarreca/master' into pr-322
2 parents
a2ebe03a
109c157e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
docs
modules/casper.js
tests/suites/casper/frames.js
docs
@
78743d45
Subproject commit
b0f51d643a839fb66c174086c426b9c7b49e2a80
Subproject commit
78743d45ac54a56fa6276ed98f46c4a3ca938c01
...
...
modules/casper.js
View file @
c132c43
...
...
@@ -1873,18 +1873,22 @@ Casper.prototype.waitWhileVisible = function waitWhileVisible(selector, then, on
* Makes the provided frame page as the currently active one. Note that the
* active page will be reverted when finished.
*
* @param String
frameName Target frame name
* @param String
|Number frameInfo Target frame name or number
* @param Function then Next step function
* @return Casper
*/
Casper
.
prototype
.
withFrame
=
function
withFrame
(
frame
Name
,
then
)
{
Casper
.
prototype
.
withFrame
=
function
withFrame
(
frame
Info
,
then
)
{
"use strict"
;
this
.
then
(
function
_step
()
{
if
(
this
.
page
.
childFramesName
().
indexOf
(
frameName
)
===
-
1
)
{
throw
new
CasperError
(
f
(
'No frame named "%s" was found.'
,
frameName
));
if
(
utils
.
isNumber
(
frameInfo
))
{
if
(
frameInfo
>
this
.
page
.
childFramesCount
()
-
1
)
{
throw
new
CasperError
(
f
(
'Frame number "%d" is out of bounds.'
,
frameInfo
));
}
}
else
if
(
this
.
page
.
childFramesName
().
indexOf
(
frameInfo
)
===
-
1
)
{
throw
new
CasperError
(
f
(
'No frame named "%s" was found.'
,
frameInfo
));
}
// make the frame page the currently active one
this
.
page
.
switchToChildFrame
(
frame
Name
);
this
.
page
.
switchToChildFrame
(
frame
Info
);
});
try
{
this
.
then
(
then
);
...
...
tests/suites/casper/frames.js
View file @
c132c43
...
...
@@ -25,7 +25,17 @@ casper.withFrame('frame2', function() {
this
.
test
.
assertTitle
(
'CasperJS frame 3'
);
});
casper
.
withFrame
(
0
,
function
()
{
this
.
test
.
assertTitle
(
'CasperJS frame 1'
);
this
.
test
.
assertExists
(
"#f1"
);
this
.
test
.
assertDoesntExist
(
"#f2"
);
});
casper
.
withFrame
(
1
,
function
()
{
this
.
test
.
assertTitle
(
'CasperJS frame 3'
);
});
casper
.
run
(
function
()
{
this
.
test
.
assertTitle
(
'CasperJS test frames'
);
this
.
test
.
done
(
1
0
);
this
.
test
.
done
(
1
4
);
});
...
...
Please
register
or
sign in
to post a comment