* Creates a condition that waits for an alert to be opened. Upon success, the * returned promise will be fulfilled with the handle for the opened alert. * * @return {!Condition<!./webdriver.Alert>} The new condition.
()
| 108 | * @return {!Condition<!./webdriver.Alert>} The new condition. |
| 109 | */ |
| 110 | function alertIsPresent() { |
| 111 | return new Condition('for alert to be present', function (driver) { |
| 112 | return driver |
| 113 | .switchTo() |
| 114 | .alert() |
| 115 | .catch(function (e) { |
| 116 | if ( |
| 117 | !( |
| 118 | e instanceof error.NoSuchAlertError || |
| 119 | // XXX: Workaround for GeckoDriver error `TypeError: can't convert null |
| 120 | // to object`. For more details, see |
| 121 | // https://github.com/SeleniumHQ/selenium/pull/2137 |
| 122 | (e instanceof error.WebDriverError && e.message === `can't convert null to object`) |
| 123 | ) |
| 124 | ) { |
| 125 | throw e |
| 126 | } |
| 127 | }) |
| 128 | }) |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Creates a condition that will wait for the current page's title to match the |