# Class TargetLocator

An interface for changing the focus of the driver to another frame or window.

#### Hierarchy

- TargetLocator

#####
Index

### Constructors

constructor

### Methods

activeElement
alert
defaultContent
frame
newWindow
parentFrame
window

## Constructors

### constructor

- new TargetLocator(driver): TargetLocator

- #### Parameters

  - ##### driver: WebDriver

    The parent driver.

  #### Returns TargetLocator

## Methods

### activeElement

- activeElement(): WebElementPromise

- Schedules a command retrieve the {@code document.activeElement} element on the current document, or {@code document.body} if activeElement is not available.

  #### Returns WebElementPromise

  The active element.

### alert

- alert(): AlertPromise

- Schedules a command to change focus to the active modal dialog, such as those opened by `window.alert()`, `window.confirm()`, and `window.prompt()`. The returned promise will be rejected with a error.NoSuchAlertError if there are no open alerts.

  #### Returns AlertPromise

  The open alert.

### defaultContent

- defaultContent(): Promise<void>

- Schedules a command to switch focus of all future commands to the first frame on the page.

  #### Returns Promise<void>

  A promise that will be resolved when the driver has changed focus to the default content.

### frame

- frame(id): Promise<void>

- 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.
  - A WebElement reference, which correspond to a `frame` or `iframe` DOM element.
  - The `null` value, to select the topmost frame on the page. Passing `null` is the same as calling #defaultContent defaultContent().

  If the specified frame can not be found, the returned promise will be rejected with a error.NoSuchFrameError.

  #### Parameters

  - ##### id: null | number | WebElement

    The frame locator.

  #### Returns Promise<void>

  A promise that will be resolved when the driver has changed focus to the specified frame.

### newWindow

- newWindow(typeHint): Promise<void>

- Creates a new browser window and switches the focus for future commands of this driver to the new window.

  #### Parameters

  - ##### typeHint: string

    'window' or 'tab'. The created window is not guaranteed to be of the requested type; if the driver does not support the requested type, a new browser window will be created of whatever type the driver does support.

  #### Returns Promise<void>

  A promise that will be resolved when the driver has changed focus to the new window.

### parentFrame

- parentFrame(): Promise<void>

- Changes the focus of all future commands to the parent frame of the currently selected frame. This command has no effect if the driver is already focused on the top-level browsing context.

  #### Returns Promise<void>

  A promise that will be resolved when the command has completed.

### window

- window(nameOrHandle): Promise<void>

- Schedules a command to switch the focus of all future commands to another window. Windows may be specified by their {@code window.name} attribute or by its handle (as returned by WebDriver#getWindowHandles).

  If the specified window cannot be found, the returned promise will be rejected with a error.NoSuchWindowError.

  #### Parameters

  - ##### nameOrHandle: string

    The name or window handle of the window to switch focus to.

  #### Returns Promise<void>

  A promise that will be resolved when the driver has changed focus to the specified window.

Generated using TypeDoc