# Class Alert

Represents a modal dialog such as {@code alert}, {@code confirm}, or {@code prompt}. Provides functions to retrieve the message displayed with the alert, accept or dismiss the alert, and set the response text (in the case of {@code prompt}).

#### Hierarchy

- Alert
  - AlertPromise

#####
Index

### Constructors

constructor

### Methods

accept
authenticateAs
dismiss
getText
sendKeys

## Constructors

### constructor

- new Alert(driver, text): Alert

- #### Parameters

  - ##### driver: WebDriver

    The driver controlling the browser this alert is attached to.

  - ##### text: string

    The message text displayed with this alert.

  #### Returns Alert

## Methods

### accept

- accept(): Promise<void>

- Accepts this alert.

  #### Returns Promise<void>

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

### authenticateAs

- authenticateAs(username, password): Promise<void>

- Sets the username and password in an alert prompting for credentials (such as a Basic HTTP Auth prompt). This method will implicitly #accept() submit the dialog.

  #### Parameters

  - ##### username: string

    The username to send.

  - ##### password: string

    The password to send.

  #### Returns Promise<void>

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

### dismiss

- dismiss(): Promise<void>

- Dismisses this alert.

  #### Returns Promise<void>

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

### getText

- getText(): Promise<string>

- Retrieves the message text displayed with this alert. For instance, if the alert were opened with alert('hello'), then this would return 'hello'.

  #### Returns Promise<string>

  A promise that will be resolved to the text displayed with this alert.

### sendKeys

- sendKeys(text): Promise<void>

- Sets the response text on this alert. This command will return an error if the underlying alert does not support response text (e.g. window.alert and window.confirm).

  #### Parameters

  - ##### text: string

    The text to set.

  #### Returns Promise<void>

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

Generated using TypeDoc