Change focus to another frame on the page.

Changes the focus of all future commands to another frame on the page. The
target frame may be specified as one of the following:

  • A number that specifies a (zero-based) index into window.frames
  • An element (css selector) which correspond to a frame or iframe
    DOM element
  • The null value, to select the topmost frame on the page.

If the specified frame can not be found, a NoSuchFrameError will be thrown

Usage

Parameters

Name Type description
frameId
Optional
string|number

Identifier for the frame to change focus to.

callback
Optional
function

Optional callback function to be called when the command finishes.

Example

 this.demoTest = function (browser) {
   browser.frame('', function(result) {
     console.log(result);
   });
}

W3C WebDriver spec