;
-
- /**
- * Calls a function for each element in an array, and if the function returns
- * true adds the element to a new array.
- *
- * If the return value of the filter function is a promise, this function
- * will wait for it to be fulfilled before determining whether to insert the
- * element into the new array.
- *
- *
If the filter function throws or returns a rejected promise, the promise
- * returned by this function will be rejected with the same reason. Only the
- * first failure will be reported; all subsequent errors will be silently
- * ignored.
- *
- * @param {!(Array.|webdriver.promise.Promise.>)} arr The
- * array to iterator over, or a promise that will resolve to said array.
- * @param {function(this: SELF, TYPE, number, !Array.): (
- * boolean|webdriver.promise.Promise.)} fn The function
- * to call for each element in the array.
- * @param {SELF=} opt_self The object to be used as the value of 'this' within
- * {@code fn}.
- * @template TYPE, SELF
- */
- function filter(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise;
- function filter(arr: webdriver.promise.Promise, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise
-
- /**
- * Creates a new deferred object.
- * @return {!webdriver.promise.Deferred} The new deferred object.
- */
- function defer(): webdriver.promise.Deferred;
-
- /**
- * Creates a promise that has been resolved with the given value.
- * @param {*=} opt_value The resolved value.
- * @return {!webdriver.promise.Promise} The resolved promise.
- */
- function fulfilled(opt_value?: T): webdriver.promise.Promise;
-
- /**
- * Calls a function for each element in an array and inserts the result into a
- * new array, which is used as the fulfillment value of the promise returned
- * by this function.
- *
- * If the return value of the mapping function is a promise, this function
- * will wait for it to be fulfilled before inserting it into the new array.
- *
- *
If the mapping function throws or returns a rejected promise, the
- * promise returned by this function will be rejected with the same reason.
- * Only the first failure will be reported; all subsequent errors will be
- * silently ignored.
- *
- * @param {!(Array.|webdriver.promise.Promise.>)} arr The
- * array to iterator over, or a promise that will resolve to said array.
- * @param {function(this: SELF, TYPE, number, !Array.): ?} fn The
- * function to call for each element in the array. This function should
- * expect three arguments (the element, the index, and the array itself.
- * @param {SELF=} opt_self The object to be used as the value of 'this' within
- * {@code fn}.
- * @template TYPE, SELF
- */
- function map(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise
- function map(arr: webdriver.promise.Promise, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise
-
- /**
- * Creates a promise that has been rejected with the given reason.
- * @param {*=} opt_reason The rejection reason; may be any value, but is
- * usually an Error or a string.
- * @return {!webdriver.promise.Promise} The rejected promise.
- */
- function rejected(opt_reason?: any): webdriver.promise.Promise;
-
- /**
- * Wraps a function that is assumed to be a node-style callback as its final
- * argument. This callback takes two arguments: an error value (which will be
- * null if the call succeeded), and the success value as the second argument.
- * If the call fails, the returned promise will be rejected, otherwise it will
- * be resolved with the result.
- * @param {!Function} fn The function to wrap.
- * @return {!webdriver.promise.Promise} A promise that will be resolved with the
- * result of the provided function's callback.
- */
- function checkedNodeCall(fn: Function, ...var_args: any[]): webdriver.promise.Promise;
-
- /**
- * Consumes a {@code GeneratorFunction}. Each time the generator yields a
- * promise, this function will wait for it to be fulfilled before feeding the
- * fulfilled value back into {@code next}. Likewise, if a yielded promise is
- * rejected, the rejection error will be passed to {@code throw}.
- *
- * Example 1: the Fibonacci Sequence.
- *
- * webdriver.promise.consume(function* fibonacci() {
- * var n1 = 1, n2 = 1;
- * for (var i = 0; i < 4; ++i) {
- * var tmp = yield n1 + n2;
- * n1 = n2;
- * n2 = tmp;
- * }
- * return n1 + n2;
- * }).then(function(result) {
- * console.log(result); // 13
- * });
- *
- *
- * Example 2: a generator that throws.
- *
- * webdriver.promise.consume(function* () {
- * yield webdriver.promise.delayed(250).then(function() {
- * throw Error('boom');
- * });
- * }).thenCatch(function(e) {
- * console.log(e.toString()); // Error: boom
- * });
- *
- *
- * @param {!Function} generatorFn The generator function to execute.
- * @param {Object=} opt_self The object to use as "this" when invoking the
- * initial generator.
- * @param {...*} var_args Any arguments to pass to the initial generator.
- * @return {!webdriver.promise.Promise.>} A promise that will resolve to the
- * generator's final result.
- * @throws {TypeError} If the given function is not a generator.
- */
- function consume(generatorFn: Function, opt_self?: any, ...var_args: any[]): webdriver.promise.Promise;
-
- /**
- * Registers an observer on a promised {@code value}, returning a new promise
- * that will be resolved when the value is. If {@code value} is not a promise,
- * then the return promise will be immediately resolved.
- * @param {*} value The value to observe.
- * @param {Function=} opt_callback The function to call when the value is
- * resolved successfully.
- * @param {Function=} opt_errback The function to call when the value is
- * rejected.
- * @return {!webdriver.promise.Promise} A new promise.
- */
- function when(value: T, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise;
- function when(value: webdriver.promise.Promise, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise;
-
- /**
- * Returns a promise that will be resolved with the input value in a
- * fully-resolved state. If the value is an array, each element will be fully
- * resolved. Likewise, if the value is an object, all keys will be fully
- * resolved. In both cases, all nested arrays and objects will also be
- * fully resolved. All fields are resolved in place; the returned promise will
- * resolve on {@code value} and not a copy.
- *
- * Warning: This function makes no checks against objects that contain
- * cyclical references:
- *
- * var value = {};
- * value['self'] = value;
- * webdriver.promise.fullyResolved(value); // Stack overflow.
- *
- * @param {*} value The value to fully resolve.
- * @return {!webdriver.promise.Promise} A promise for a fully resolved version
- * of the input value.
- */
- function fullyResolved(value: any): webdriver.promise.Promise;
-
- /**
- * Changes the default flow to use when no others are active.
- * @param {!webdriver.promise.ControlFlow} flow The new default flow.
- * @throws {Error} If the default flow is not currently active.
- */
- function setDefaultFlow(flow: webdriver.promise.ControlFlow): void;
- }
-
- namespace stacktrace {
- class Frame extends webdriver.stacktrace.Frame { }
- class Snapshot extends webdriver.stacktrace.Snapshot { }
-
- /**
- * Formats an error's stack trace.
- * @param {!(Error|goog.testing.JsUnitException)} error The error to format.
- * @return {!(Error|goog.testing.JsUnitException)} The formatted error.
- */
- function format(error: any): any;
-
- /**
- * Gets the native stack trace if available otherwise follows the call chain.
- * The generated trace will exclude all frames up to and including the call to
- * this function.
- * @return {!Array.} The frames of the stack trace.
- */
- function get(): webdriver.stacktrace.Frame[];
-
- /**
- * Whether the current browser supports stack traces.
- *
- * @type {boolean}
- * @const
- */
- var BROWSER_SUPPORTED: boolean;
- }
-
- namespace until {
- class Condition extends webdriver.until.Condition { }
-
- /**
- * Creates a condition that will wait until the input driver is able to switch
- * to the designated frame. The target frame may be specified as:
- *
- * - A numeric index into {@code window.frames} for the currently selected
- * frame.
- *
- A {@link webdriver.WebElement}, which must reference a FRAME or IFRAME
- * element on the current page.
- *
- A locator which may be used to first locate a FRAME or IFRAME on the
- * current page before attempting to switch to it.
- *
- *
- * Upon successful resolution of this condition, the driver will be left
- * focused on the new frame.
- *
- * @param {!(number|webdriver.WebElement|
- * webdriver.Locator|webdriver.By.Hash|
- * function(!webdriver.WebDriver): !webdriver.WebElement)} frame
- * The frame identifier.
- * @return {!until.Condition.} A new condition.
- */
- function ableToSwitchToFrame(frame: number): webdriver.until.Condition;
- function ableToSwitchToFrame(frame: webdriver.IWebElement): webdriver.until.Condition;
- function ableToSwitchToFrame(frame: webdriver.Locator): webdriver.until.Condition;
- function ableToSwitchToFrame(frame: (webdriver: webdriver.WebDriver) => webdriver.IWebElement): webdriver.until.Condition;
- function ableToSwitchToFrame(frame: any): webdriver.until.Condition;
-
- /**
- * 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 {!until.Condition.} The new condition.
- */
- function alertIsPresent(): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element to be disabled.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#isEnabled
- */
- function elementIsDisabled(element: webdriver.IWebElement): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element to be enabled.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#isEnabled
- */
- function elementIsEnabled(element: webdriver.IWebElement): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element to be deselected.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#isSelected
- */
- function elementIsNotSelected(element: webdriver.IWebElement): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element to be in the DOM,
- * yet not visible to the user.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#isDisplayed
- */
- function elementIsNotVisible(element: webdriver.IWebElement): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element to be selected.
- * @param {!webdriver.WebElement} element The element to test.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#isSelected
- */
- function elementIsSelected(element: webdriver.IWebElement): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element to become visible.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#isDisplayed
- */
- function elementIsVisible(element: webdriver.IWebElement): webdriver.until.Condition;
-
- /**
- * Creates a condition that will loop until an element is
- * {@link webdriver.WebDriver#findElement found} with the given locator.
- *
- * @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The locator
- * to use.
- * @return {!until.Condition.} The new condition.
- */
- function elementLocated(locator: webdriver.Locator): webdriver.until.Condition;
- function elementLocated(locator: any): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element's
- * {@link webdriver.WebDriver#getText visible text} to contain the given
- * substring.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @param {string} substr The substring to search for.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#getText
- */
- function elementTextContains(element: webdriver.IWebElement, substr: string): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element's
- * {@link webdriver.WebDriver#getText visible text} to match the given
- * {@code text} exactly.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @param {string} text The expected text.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#getText
- */
- function elementTextIs(element: webdriver.IWebElement, text: string): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element's
- * {@link webdriver.WebDriver#getText visible text} to match a regular
- * expression.
- *
- * @param {!webdriver.WebElement} element The element to test.
- * @param {!RegExp} regex The regular expression to test against.
- * @return {!until.Condition.} The new condition.
- * @see webdriver.WebDriver#getText
- */
- function elementTextMatches(element: webdriver.IWebElement, regex: RegExp): webdriver.until.Condition;
-
- /**
- * Creates a condition that will loop until at least one element is
- * {@link webdriver.WebDriver#findElement found} with the given locator.
- *
- * @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The locator
- * to use.
- * @return {!until.Condition.>} The new
- * condition.
- */
- function elementsLocated(locator: webdriver.Locator): webdriver.until.Condition;
- function elementsLocated(locator: any): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the given element to become stale. An
- * element is considered stale once it is removed from the DOM, or a new page
- * has loaded.
- *
- * @param {!webdriver.WebElement} element The element that should become stale.
- * @return {!until.Condition.} The new condition.
- */
- function stalenessOf(element: webdriver.IWebElement): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the current page's title to contain
- * the given substring.
- *
- * @param {string} substr The substring that should be present in the page
- * title.
- * @return {!until.Condition.} The new condition.
- */
- function titleContains(substr: string): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the current page's title to match the
- * given value.
- *
- * @param {string} title The expected page title.
- * @return {!until.Condition.} The new condition.
- */
- function titleIs(title: string): webdriver.until.Condition;
-
- /**
- * Creates a condition that will wait for the current page's title to match the
- * given regular expression.
- *
- * @param {!RegExp} regex The regular expression to test against.
- * @return {!until.Condition.} The new condition.
- */
- function titleMatches(regex: RegExp): webdriver.until.Condition;
- }
-
- namespace ExpectedConditions {
- /**
- * Negates the result of a promise.
- *
- * @param {webdriver.until.Condition} expectedCondition
- * @return {!webdriver.until.Condition} An expected condition that returns the negated value.
- */
- function not(expectedCondition: webdriver.until.Condition): webdriver.until.Condition;
-
- /**
- * Chain a number of expected conditions using logical_and, short circuiting at the
- * first expected condition that evaluates to false.
- *
- * @param {...webdriver.until.Condition[]} fns An array of expected conditions to 'and' together.
- * @return {!webdriver.until.Condition} An expected condition that returns a promise which evaluates
- * to the result of the logical and.
- */
- function and(...fns: webdriver.until.Condition[]): webdriver.until.Condition;
-
- /**
- * Chain a number of expected conditions using logical_or, short circuiting at the
- * first expected condition that evaluates to true.
- *
- * @param {...webdriver.until.Condition[]} fns An array of expected conditions to 'or' together.
- * @return {!webdriver.until.Condition} An expected condition that returns a promise which
- * evaluates to the result of the logical or.
- */
- function or(...fns: webdriver.until.Condition[]): webdriver.until.Condition;
-
- /**
- * Expect an alert to be present.
- *
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether an alert is present.
- */
- function alertIsPresent(): webdriver.until.Condition;
-
- /**
- * An Expectation for checking an element is visible and enabled such that you can click it.
- *
- * @param {ElementFinder} element The element to check
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the element is clickable.
- */
- function elementToBeClickable(element: ElementFinder): webdriver.until.Condition;
-
- /**
- * An expectation for checking if the given text is present in the element.
- * Returns false if the elementFinder does not find an element.
- *
- * @param {ElementFinder} element The element to check
- * @param {string} text The text to verify against
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the text is present in the element.
- */
- function textToBePresentInElement(element: ElementFinder, text: string): webdriver.until.Condition;
-
- /**
- * An expectation for checking if the given text is present in the element’s value.
- * Returns false if the elementFinder does not find an element.
- *
- * @param {ElementFinder} element The element to check
- * @param {string} text The text to verify against
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the text is present in the element's value.
- */
- function textToBePresentInElementValue(
- element: ElementFinder, text: string
- ): webdriver.until.Condition;
-
- /**
- * An expectation for checking that the title contains a case-sensitive substring.
- *
- * @param {string} title The fragment of title expected
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the title contains the string.
- */
- function titleContains(title: string): webdriver.until.Condition;
-
- /**
- * An expectation for checking the title of a page.
- *
- * @param {string} title The expected title, which must be an exact match.
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the title equals the string.
- */
- function titleIs(title: string): webdriver.until.Condition;
-
- /**
- * An expectation for checking that an element is present on the DOM of a page. This does not necessarily
- * mean that the element is visible. This is the opposite of 'stalenessOf'.
- *
- * @param {ElementFinder} elementFinder The element to check
- * @return {!webdriver.until.Condition} An expected condition that returns a promise
- * representing whether the element is present.
- */
- function presenceOf(element: ElementFinder): webdriver.until.Condition;
-
- /**
- * An expectation for checking that an element is not attached to the DOM of a page.
- * This is the opposite of 'presenceOf'.
- *
- * @param {ElementFinder} elementFinder The element to check
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the element is stale.
- */
- function stalenessOf(element: ElementFinder): webdriver.until.Condition;
-
- /**
- * An expectation for checking that an element is present on the DOM of a page and visible.
- * Visibility means that the element is not only displayed but also has a height and width that is
- * greater than 0. This is the opposite of 'invisibilityOf'.
- *
- * @param {ElementFinder} elementFinder The element to check
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the element is visible.
- */
- function visibilityOf(element: ElementFinder): webdriver.until.Condition;
-
- /**
- * An expectation for checking that an element is present on the DOM of a page. This does not necessarily
- * mean that the element is visible. This is the opposite of 'stalenessOf'.
- *
- * @param {ElementFinder} elementFinder The element to check
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the element is invisible.
- */
- function invisibilityOf(element: ElementFinder): webdriver.until.Condition;
-
- /**
- * An expectation for checking the selection is selected.
- *
- * @param {ElementFinder} elementFinder The element to check
- * @return {!webdriver.until.Condition} An expected condition that returns a promise representing
- * whether the element is selected.
- */
- function elementToBeSelected(element: ElementFinder): webdriver.until.Condition