MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / alertIsPresent

Function alertIsPresent

javascript/selenium-webdriver/lib/until.js:110–127  ·  view source on GitHub ↗

* 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.

()

Source from the content-addressed store, hash-verified

108 * @return {!Condition<!./webdriver.Alert>} The new condition.
109 */
110function 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 e instanceof error.NoSuchAlertError ||
118 // XXX: Workaround for GeckoDriver error `TypeError: can't convert null
119 // to object`. For more details, see
120 // https://github.com/SeleniumHQ/selenium/pull/2137
121 (e instanceof error.WebDriverError && e.message === `can't convert null to object`)
122 )) {
123 throw e
124 }
125 })
126 })
127}
128
129/**
130 * Creates a condition that will wait for the current page's title to match the

Callers

nothing calls this directly

Calls 2

alertMethod · 0.65
switchToMethod · 0.65

Tested by

no test coverage detected