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
a8afb075
...
a8afb075246a1fb8d49176c4e89745231a94dffc
authored
2012-12-14 17:39:49 -1000
by
Rob Barreca
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Support frame number in withFrame().
1 parent
3d17e643
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
modules/casper.js
modules/casper.js
View file @
a8afb07
...
...
@@ -1870,18 +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
frameName Target frame name
* @param String
|Number frameNameOrNumber Target frame name or number
* @param Function then Next step function
* @return Casper
*/
Casper
.
prototype
.
withFrame
=
function
withFrame
(
frameName
,
then
)
{
Casper
.
prototype
.
withFrame
=
function
withFrame
(
frameName
OrNumber
,
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
(
frameNameOrNumber
))
{
if
(
frameNameOrNumber
>
this
.
page
.
childFramesCount
()
-
1
)
{
throw
new
CasperError
(
f
(
'Frame number "%d" is out of bounds.'
,
frameNameOrNumber
));
}
}
else
if
(
this
.
page
.
childFramesName
().
indexOf
(
frameNameOrNumber
)
===
-
1
)
{
throw
new
CasperError
(
f
(
'No frame named "%s" was found.'
,
frameNameOrNumber
));
}
// make the frame page the currently active one
this
.
page
.
switchToChildFrame
(
frameName
);
this
.
page
.
switchToChildFrame
(
frameName
OrNumber
);
});
try
{
this
.
then
(
then
);
...
...
Please
register
or
sign in
to post a comment