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

Example

Or run locally with:
git clone https://github.com/nightwatchjs/nightwatch-examples.git
cd nightwatch-examples
npm install
npx nightwatch tests/api/frame.js

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.

W3C WebDriver spec