Commit c132c434 c132c434f6ea75559fb419495d3bcc356d022306 by Nicolas Perriault

Merge remote-tracking branch 'rbarreca/master' into pr-322

2 parents a2ebe03a 109c157e
Subproject commit b0f51d643a839fb66c174086c426b9c7b49e2a80
Subproject commit 78743d45ac54a56fa6276ed98f46c4a3ca938c01
......
......@@ -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(frameName, then) {
Casper.prototype.withFrame = function withFrame(frameInfo, 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(frameName);
this.page.switchToChildFrame(frameInfo);
});
try {
this.then(then);
......
......@@ -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(10);
this.test.done(14);
});
......