* Represents a modal dialog such as alert, confirm, or * 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 prompt).
| 3396 | * case of {@code prompt}). |
| 3397 | */ |
| 3398 | class Alert { |
| 3399 | /** |
| 3400 | * @param {!WebDriver} driver The driver controlling the browser this alert |
| 3401 | * is attached to. |
| 3402 | * @param {string} text The message text displayed with this alert. |
| 3403 | */ |
| 3404 | constructor(driver, text) { |
| 3405 | /** @private {!WebDriver} */ |
| 3406 | this.driver_ = driver |
| 3407 | |
| 3408 | /** @private {!Promise<string>} */ |
| 3409 | this.text_ = Promise.resolve(text) |
| 3410 | } |
| 3411 | |
| 3412 | /** |
| 3413 | * Retrieves the message text displayed with this alert. For instance, if the |
| 3414 | * alert were opened with alert("hello"), then this would return "hello". |
| 3415 | * |
| 3416 | * @return {!Promise<string>} A promise that will be |
| 3417 | * resolved to the text displayed with this alert. |
| 3418 | */ |
| 3419 | getText() { |
| 3420 | return this.text_ |
| 3421 | } |
| 3422 | |
| 3423 | /** |
| 3424 | * Accepts this alert. |
| 3425 | * |
| 3426 | * @return {!Promise<void>} A promise that will be resolved |
| 3427 | * when this command has completed. |
| 3428 | */ |
| 3429 | accept() { |
| 3430 | return this.driver_.execute(new command.Command(command.Name.ACCEPT_ALERT)) |
| 3431 | } |
| 3432 | |
| 3433 | /** |
| 3434 | * Dismisses this alert. |
| 3435 | * |
| 3436 | * @return {!Promise<void>} A promise that will be resolved |
| 3437 | * when this command has completed. |
| 3438 | */ |
| 3439 | dismiss() { |
| 3440 | return this.driver_.execute(new command.Command(command.Name.DISMISS_ALERT)) |
| 3441 | } |
| 3442 | |
| 3443 | /** |
| 3444 | * Sets the response text on this alert. This command will return an error if |
| 3445 | * the underlying alert does not support response text (e.g. window.alert and |
| 3446 | * window.confirm). |
| 3447 | * |
| 3448 | * @param {string} text The text to set. |
| 3449 | * @return {!Promise<void>} A promise that will be resolved |
| 3450 | * when this command has completed. |
| 3451 | */ |
| 3452 | sendKeys(text) { |
| 3453 | return this.driver_.execute(new command.Command(command.Name.SET_ALERT_TEXT).setParameter('text', text)) |
| 3454 | } |
| 3455 | } |
nothing calls this directly
no outgoing calls
no test coverage detected