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
2b0a2025
...
2b0a20258f978713cc59c50c3f17a60e989b8efd
authored
2012-12-17 19:12:16 -1000
by
Rob Barreca
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added some basic tests for withFrame(Number).
1 parent
50a1ffbf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
modules/casper.js
tests/suites/casper/frames.js
modules/casper.js
View file @
2b0a202
...
...
@@ -1870,22 +1870,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|Number frame
NameOrNumber
Target frame name or number
* @param String|Number frame
Info
Target frame name or number
* @param Function then Next step function
* @return Casper
*/
Casper
.
prototype
.
withFrame
=
function
withFrame
(
frame
NameOrNumber
,
then
)
{
Casper
.
prototype
.
withFrame
=
function
withFrame
(
frame
Info
,
then
)
{
"use strict"
;
this
.
then
(
function
_step
()
{
if
(
utils
.
isNumber
(
frame
NameOrNumber
))
{
if
(
frame
NameOrNumber
>
this
.
page
.
childFramesCount
()
-
1
)
{
throw
new
CasperError
(
f
(
'Frame number "%d" is out of bounds.'
,
frame
NameOrNumber
));
if
(
utils
.
isNumber
(
frame
Info
))
{
if
(
frame
Info
>
this
.
page
.
childFramesCount
()
-
1
)
{
throw
new
CasperError
(
f
(
'Frame number "%d" is out of bounds.'
,
frame
Info
));
}
}
else
if
(
this
.
page
.
childFramesName
().
indexOf
(
frame
NameOrNumber
)
===
-
1
)
{
throw
new
CasperError
(
f
(
'No frame named "%s" was found.'
,
frame
NameOrNumber
));
}
else
if
(
this
.
page
.
childFramesName
().
indexOf
(
frame
Info
)
===
-
1
)
{
throw
new
CasperError
(
f
(
'No frame named "%s" was found.'
,
frame
Info
));
}
// make the frame page the currently active one
this
.
page
.
switchToChildFrame
(
frame
NameOrNumber
);
this
.
page
.
switchToChildFrame
(
frame
Info
);
});
try
{
this
.
then
(
then
);
...
...
tests/suites/casper/frames.js
View file @
2b0a202
...
...
@@ -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