mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-19 13:32:17 +08:00
Removes deprecated methods and updates some signatures
This commit is contained in:
11
selenium-webdriver/executors.d.ts
vendored
11
selenium-webdriver/executors.d.ts
vendored
@@ -1,11 +0,0 @@
|
||||
import * as webdriver from './index';
|
||||
|
||||
/**
|
||||
* Creates a command executor that uses WebDriver's JSON wire protocol.
|
||||
* @param {(string|!promise.Promise<string>)} url The server's URL,
|
||||
* or a promise that will resolve to that URL.
|
||||
* @param {?string=} opt_proxy (optional) The URL of the HTTP proxy for the
|
||||
* client to use.
|
||||
* @returns {!./lib/command.Executor} The new command executor.
|
||||
*/
|
||||
export function createExecutor(url: string | webdriver.promise.Promise<string>, opt_agent?: string, opt_proxy?: string): webdriver.Executor;
|
||||
8
selenium-webdriver/firefox.d.ts
vendored
8
selenium-webdriver/firefox.d.ts
vendored
@@ -197,11 +197,13 @@ export class Options {
|
||||
setProxy(proxy: webdriver.ProxyConfig): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to use Mozilla's Marionette to drive the browser.
|
||||
* Sets whether to use Mozilla's geckodriver to drive the browser. This option
|
||||
* is enabled by default and required for Firefox 47+.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
|
||||
* @param {boolean} enable Whether to enable the geckodriver.
|
||||
* @see https://github.com/mozilla/geckodriver
|
||||
*/
|
||||
useMarionette(marionette: any): Options;
|
||||
useGeckoDriver(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Converts these options to a {@link capabilities.Capabilities} instance.
|
||||
|
||||
7
selenium-webdriver/http.d.ts
vendored
7
selenium-webdriver/http.d.ts
vendored
@@ -99,10 +99,11 @@ export function sendRequest(options: Object, onOk: any, onError: any, opt_data?:
|
||||
*/
|
||||
export class Executor {
|
||||
/**
|
||||
* @param {!HttpClient} client The client to use for sending requests to the
|
||||
* server.
|
||||
* @param {!(HttpClient|IThenable<!HttpClient>)} client The client to use for sending
|
||||
* requests to the server, or a promise-like object that will resolve to
|
||||
* to the client.
|
||||
*/
|
||||
constructor(client: HttpClient);
|
||||
constructor(client: HttpClient | webdriver.promise.IThenable<HttpClient>);
|
||||
|
||||
/**
|
||||
* Defines a new command for use with this executor. When a command is sent,
|
||||
|
||||
383
selenium-webdriver/index.d.ts
vendored
383
selenium-webdriver/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Selenium WebDriverJS 2.53
|
||||
// Type definitions for Selenium WebDriverJS 3.0.1
|
||||
// Project: https://github.com/SeleniumHQ/selenium/tree/master/javascript/node/selenium-webdriver
|
||||
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>, Yuki Kokubun <https://github.com/Kuniwak>, Craig Nishina <https://github.com/cnishina>
|
||||
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>, Yuki Kokubun <https://github.com/Kuniwak>, Craig Nishina <https://github.com/cnishina>, Simon Gellis <https://github.com/SupernaviX>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
@@ -14,8 +14,6 @@ import * as safari from './safari';
|
||||
export namespace error {
|
||||
class IError extends Error {
|
||||
constructor(opt_error?: string);
|
||||
|
||||
code(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1037,32 +1035,6 @@ export namespace promise {
|
||||
*/
|
||||
then<R>(opt_callback?: (value: T) => IThenable<R> | R, opt_errback?: (error: any) => any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Registers a listener for when this promise is rejected. This is synonymous
|
||||
* with the {@code catch} clause in a synchronous API:
|
||||
* <pre><code>
|
||||
* // Synchronous API:
|
||||
* try {
|
||||
* doSynchronousWork();
|
||||
* } catch (ex) {
|
||||
* console.error(ex);
|
||||
* }
|
||||
*
|
||||
* // Asynchronous promise API:
|
||||
* doAsynchronousWork().thenCatch(function(ex) {
|
||||
* console.error(ex);
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
* @param {function(*): (R|promise.Promise.<R>)} errback The function
|
||||
* to call if this promise is rejected. The function should expect a single
|
||||
* argument: the rejection reason.
|
||||
* @return {!promise.Promise.<R>} A new promise which will be
|
||||
* resolved with the result of the invoked callback.
|
||||
* @template R
|
||||
*/
|
||||
thenCatch<R>(errback: (error: any) => any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Registers a listener for when this promise is rejected. This is synonymous
|
||||
* with the {@code catch} clause in a synchronous API:
|
||||
@@ -1089,47 +1061,6 @@ export namespace promise {
|
||||
catch<R>(errback: Function): Promise<R>;
|
||||
|
||||
|
||||
/**
|
||||
* Registers a listener to invoke when this promise is resolved, regardless
|
||||
* of whether the promise's value was successfully computed. This function
|
||||
* is synonymous with the {@code finally} clause in a synchronous API:
|
||||
* <pre><code>
|
||||
* // Synchronous API:
|
||||
* try {
|
||||
* doSynchronousWork();
|
||||
* } finally {
|
||||
* cleanUp();
|
||||
* }
|
||||
*
|
||||
* // Asynchronous promise API:
|
||||
* doAsynchronousWork().thenFinally(cleanUp);
|
||||
* </code></pre>
|
||||
*
|
||||
* <b>Note:</b> similar to the {@code finally} clause, if the registered
|
||||
* callback returns a rejected promise or throws an error, it will silently
|
||||
* replace the rejection error (if any) from this promise:
|
||||
* <pre><code>
|
||||
* try {
|
||||
* throw Error('one');
|
||||
* } finally {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* }
|
||||
*
|
||||
* promise.rejected(Error('one'))
|
||||
* .thenFinally(function() {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
*
|
||||
* @param {function(): (R|promise.Promise.<R>)} callback The function
|
||||
* to call when this promise is resolved.
|
||||
* @return {!promise.Promise.<R>} A promise that will be fulfilled
|
||||
* with the callback result.
|
||||
* @template R
|
||||
*/
|
||||
thenFinally<R>(callback: Function): Promise<R>;
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
@@ -1144,13 +1075,8 @@ export namespace promise {
|
||||
* the next turn of the event loop, the rejection will be passed to the
|
||||
* {@link promise.ControlFlow} as an unhandled failure.
|
||||
*
|
||||
* <p>If this Deferred is cancelled, the cancellation reason will be forward to
|
||||
* the Deferred's canceller function (if provided). The canceller may return a
|
||||
* truth-y value to override the reason provided for rejection.
|
||||
*
|
||||
* @extends {promise.Promise}
|
||||
*/
|
||||
class Deferred<T> extends Promise<T> {
|
||||
class Deferred<T> {
|
||||
// region Constructors
|
||||
|
||||
/**
|
||||
@@ -2121,32 +2047,6 @@ export class AlertPromise extends Alert implements promise.IThenable<Alert> {
|
||||
*/
|
||||
then(opt_callback?: Function, opt_errback?: Function): promise.Promise<any>;
|
||||
|
||||
/**
|
||||
* Registers a listener for when this promise is rejected. This is synonymous
|
||||
* with the {@code catch} clause in a synchronous API:
|
||||
* <pre><code>
|
||||
* // Synchronous API:
|
||||
* try {
|
||||
* doSynchronousWork();
|
||||
* } catch (ex) {
|
||||
* console.error(ex);
|
||||
* }
|
||||
*
|
||||
* // Asynchronous promise API:
|
||||
* doAsynchronousWork().thenCatch(function(ex) {
|
||||
* console.error(ex);
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
* @param {function(*): (R|promise.Promise.<R>)} errback The function
|
||||
* to call if this promise is rejected. The function should expect a single
|
||||
* argument: the rejection reason.
|
||||
* @return {!promise.Promise.<R>} A new promise which will be
|
||||
* resolved with the result of the invoked callback.
|
||||
* @template R
|
||||
*/
|
||||
thenCatch<R>(errback: (error: any) => any): promise.Promise<R>;
|
||||
|
||||
/**
|
||||
* Registers a listener for when this promise is rejected. This is synonymous
|
||||
* with the {@code catch} clause in a synchronous API:
|
||||
@@ -2171,52 +2071,6 @@ export class AlertPromise extends Alert implements promise.IThenable<Alert> {
|
||||
* @template R
|
||||
*/
|
||||
catch<R>(errback: Function): promise.Promise<R>;
|
||||
|
||||
|
||||
/**
|
||||
* Registers a listener to invoke when this promise is resolved, regardless
|
||||
* of whether the promise's value was successfully computed. This function
|
||||
* is synonymous with the {@code finally} clause in a synchronous API:
|
||||
* <pre><code>
|
||||
* // Synchronous API:
|
||||
* try {
|
||||
* doSynchronousWork();
|
||||
* } finally {
|
||||
* cleanUp();
|
||||
* }
|
||||
*
|
||||
* // Asynchronous promise API:
|
||||
* doAsynchronousWork().thenFinally(cleanUp);
|
||||
* </code></pre>
|
||||
*
|
||||
* <b>Note:</b> similar to the {@code finally} clause, if the registered
|
||||
* callback returns a rejected promise or throws an error, it will silently
|
||||
* replace the rejection error (if any) from this promise:
|
||||
* <pre><code>
|
||||
* try {
|
||||
* throw Error('one');
|
||||
* } finally {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* }
|
||||
*
|
||||
* promise.rejected(Error('one'))
|
||||
* .thenFinally(function() {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
*
|
||||
* @param {function(): (R|promise.Promise.<R>)} callback The function
|
||||
* to call when this promise is resolved.
|
||||
* @return {!promise.Promise.<R>} A promise that will be fulfilled
|
||||
* with the callback result.
|
||||
* @template R
|
||||
*/
|
||||
thenFinally<R>(callback: Function): promise.Promise<R>;
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link error.UnexpectedAlertOpenError} instead. */
|
||||
export class UnhandledAlertError extends error.UnexpectedAlertOpenError {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2495,6 +2349,15 @@ export class Builder {
|
||||
setScrollBehavior(behavior: number): Builder;
|
||||
|
||||
/**
|
||||
* Sets the http agent to use for each request.
|
||||
* If this method is not called, the Builder will use http.globalAgent by default.
|
||||
*
|
||||
* @param {http.Agent} agent The agent to use for each request.
|
||||
* @return {!Builder} A self reference.
|
||||
*/
|
||||
usingHttpAgent(agent: any): Builder;
|
||||
|
||||
/**
|
||||
* Sets the URL of a remote WebDriver server to use. Once a remote URL has been
|
||||
* specified, the builder direct all new clients to that server. If this method
|
||||
* is never called, the Builder will attempt to create all clients locally.
|
||||
@@ -3122,19 +2985,6 @@ export class Executor {
|
||||
execute(command: Command): promise.Promise<any>
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps a promised {@link Executor}, ensuring no commands are executed until
|
||||
* the wrapped executor has been fully resolved.
|
||||
* @implements {Executor}
|
||||
*/
|
||||
export class DeferredExecutor {
|
||||
/**
|
||||
* @param {!promise.Promise<Executor>} delegate The promised delegate, which
|
||||
* may be provided by any promise-like thenable object.
|
||||
*/
|
||||
constructor(delegate: promise.Promise<Executor>);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes an event listener registered on an {@linkplain EventEmitter}.
|
||||
*/
|
||||
@@ -3287,12 +3137,53 @@ export class Navigation {
|
||||
}
|
||||
|
||||
interface IWebDriverOptionsCookie {
|
||||
|
||||
/**
|
||||
* The name of the cookie.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The cookie value.
|
||||
*/
|
||||
value: string;
|
||||
|
||||
/**
|
||||
* The cookie path. Defaults to "/" when adding a cookie.
|
||||
*/
|
||||
path?: string;
|
||||
|
||||
/**
|
||||
* The domain the cookie is visible to. Defaults to the current browsing
|
||||
* context's document's URL when adding a cookie.
|
||||
*/
|
||||
domain?: string;
|
||||
|
||||
/**
|
||||
* Whether the cookie is a secure cookie. Defaults to false when adding a new
|
||||
* cookie.
|
||||
*/
|
||||
secure?: boolean;
|
||||
expiry?: number;
|
||||
|
||||
/**
|
||||
* Whether the cookie is an HTTP only cookie. Defaults to false when adding a
|
||||
* new cookie.
|
||||
*/
|
||||
httpOnly?: boolean;
|
||||
|
||||
/**
|
||||
* When the cookie expires.
|
||||
*
|
||||
* When {@linkplain Options#addCookie() adding a cookie}, this may be specified
|
||||
* in _seconds_ since Unix epoch (January 1, 1970). The expiry will default to
|
||||
* 20 years in the future if omitted.
|
||||
*
|
||||
* The expiry is always returned in seconds since epoch when
|
||||
* {@linkplain Options#getCookies() retrieving cookies} from the browser.
|
||||
*
|
||||
* @type {(!Date|number|undefined)}
|
||||
*/
|
||||
expiry?: number | Date;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3313,18 +3204,14 @@ export class Options {
|
||||
|
||||
/**
|
||||
* Schedules a command to add a cookie.
|
||||
* @param {string} name The cookie name.
|
||||
* @param {string} value The cookie value.
|
||||
* @param {string=} opt_path The cookie path.
|
||||
* @param {string=} opt_domain The cookie domain.
|
||||
* @param {boolean=} opt_isSecure Whether the cookie is secure.
|
||||
* @param {(number|!Date)=} opt_expiry When the cookie expires. If specified
|
||||
* as a number, should be in milliseconds since midnight,
|
||||
* January 1, 1970 UTC.
|
||||
* @param {IWebDriverOptionsCookie} spec Defines the cookie to add.
|
||||
* @return {!promise.Promise<void>} A promise that will be resolved
|
||||
* when the cookie has been added to the page.
|
||||
* @throws {error.InvalidArgumentError} if any of the cookie parameters are
|
||||
* invalid.
|
||||
* @throws {TypeError} if `spec` is not a cookie object.
|
||||
*/
|
||||
addCookie(name: string, value: string, opt_path?: string, opt_domain?: string, opt_isSecure?: boolean, opt_expiry?: number | Date): promise.Promise<void>;
|
||||
addCookie(spec: IWebDriverOptionsCookie): webdriver.promise.Promise<void>;
|
||||
|
||||
/**
|
||||
* Schedules a command to delete all cookies visible to the current page.
|
||||
@@ -4061,7 +3948,7 @@ export class WebDriver {
|
||||
* by the driver. Unlike other commands, this error cannot be suppressed. In
|
||||
* other words, scheduling a command to find an element doubles as an assert
|
||||
* that the element is present on the page. To test whether an element is
|
||||
* present on the page, use {@link #isElementPresent} instead.
|
||||
* present on the page, use {@link #findElements}.
|
||||
*
|
||||
* The search criteria for an element may be defined using one of the
|
||||
* factories in the {@link By} namespace, or as a short-hand
|
||||
@@ -4093,24 +3980,6 @@ export class WebDriver {
|
||||
*/
|
||||
findElement(locator: By | Function): WebElementPromise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if an element is present on the page.
|
||||
*
|
||||
* If given a DOM element, this function will check if it belongs to the
|
||||
* document the driver is currently focused on. Otherwise, the function will
|
||||
* test if at least one element can be found with the given search criteria.
|
||||
*
|
||||
* @param {!(by.By|Function)} locator The locator to use.
|
||||
* @return {!promise.Promise<boolean>} A promise that will resolve
|
||||
* with whether the element is present on the page.
|
||||
* @deprecated This method will be removed in Selenium 3.0 for consistency
|
||||
* with the other Selenium language bindings. This method is equivalent
|
||||
* to
|
||||
*
|
||||
* driver.findElements(locator).then(e => !!e.length);
|
||||
*/
|
||||
isElementPresent(locatorOrElement: By | Function): promise.Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Schedule a command to search for multiple elements on the page.
|
||||
*
|
||||
@@ -4366,13 +4235,6 @@ interface IWebElement {
|
||||
*/
|
||||
isDisplayed(): promise.Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the outer HTML of this element.
|
||||
* @return {!promise.Promise} A promise that will be resolved with
|
||||
* the element's outer HTML.
|
||||
*/
|
||||
getOuterHtml(): promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* @return {!promise.Promise.<WebElement.Id>} A promise
|
||||
* that resolves to this element's JSON representation as defined by the
|
||||
@@ -4381,13 +4243,6 @@ interface IWebElement {
|
||||
*/
|
||||
getId(): promise.Promise<IWebElementId>;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the inner HTML of this element.
|
||||
* @return {!promise.Promise} A promise that will be resolved with the
|
||||
* element's inner HTML.
|
||||
*/
|
||||
getInnerHtml(): promise.Promise<string>;
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
@@ -4398,7 +4253,7 @@ interface IWebElementFinders {
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* element is present on the page, use {@code #findElements}.
|
||||
*
|
||||
* <p>The search criteria for an element may be defined using one of the
|
||||
* factories in the {@link By} namespace, or as a short-hand
|
||||
@@ -4434,17 +4289,6 @@ interface IWebElementFinders {
|
||||
*/
|
||||
findElement(locator: By | Function): WebElementPromise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if there is at least one descendant of this
|
||||
* element that matches the given search criteria.
|
||||
*
|
||||
* @param {!(Locator|By.Hash|Function)} locator The
|
||||
* locator strategy to use when searching for the element.
|
||||
* @return {!promise.Promise.<boolean>} A promise that will be
|
||||
* resolved with whether an element could be located on the page.
|
||||
*/
|
||||
isElementPresent(locator: By | Function): promise.Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Schedules a command to find all of the descendants of this element that
|
||||
* match the given search criteria.
|
||||
@@ -4551,18 +4395,13 @@ export class WebElement implements Serializable<IWebElementId> {
|
||||
*/
|
||||
getId(): promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getId()} instead.
|
||||
*/
|
||||
getRawId(): any;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@link bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@link #isElementPresent} instead.
|
||||
* element is present on the page, use {@link #findElements}.
|
||||
*
|
||||
* The search criteria for an element may be defined using one of the
|
||||
* factories in the {@link By} namespace, or as a short-hand
|
||||
@@ -4596,22 +4435,6 @@ export class WebElement implements Serializable<IWebElementId> {
|
||||
*/
|
||||
findElement(locator: By | Function): WebElementPromise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if there is at least one descendant of this
|
||||
* element that matches the given search criteria.
|
||||
*
|
||||
* @param {!(by.By|Function)} locator The locator strategy to use when
|
||||
* searching for the element.
|
||||
* @return {!promise.Promise<boolean>} A promise that will be
|
||||
* resolved with whether an element could be located on the page.
|
||||
* @deprecated This method will be removed in Selenium 3.0 for consistency
|
||||
* with the other Selenium language bindings. This method is equivalent
|
||||
* to
|
||||
*
|
||||
* element.findElements(locator).then(e => !!e.length);
|
||||
*/
|
||||
isElementPresent(locator: By | Function): promise.Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Schedules a command to find all of the descendants of this element that
|
||||
* match the given search criteria.
|
||||
@@ -4817,20 +4640,6 @@ export class WebElement implements Serializable<IWebElementId> {
|
||||
*/
|
||||
takeScreenshot(opt_scroll?: boolean): promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the outer HTML of this element.
|
||||
* @return {!promise.Promise.<string>} A promise that will be
|
||||
* resolved with the element's outer HTML.
|
||||
*/
|
||||
getOuterHtml(): promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the inner HTML of this element.
|
||||
* @return {!promise.Promise} A promise that will be resolved with the
|
||||
* element's inner HTML.
|
||||
*/
|
||||
getInnerHtml(): promise.Promise<string>;
|
||||
|
||||
/** @override */
|
||||
serialize(): promise.Promise<IWebElementId>;
|
||||
}
|
||||
@@ -4908,74 +4717,6 @@ export class WebElementPromise extends WebElement implements promise.IThenable<W
|
||||
then<R>(opt_callback?: (value: WebElement) => R, opt_errback?: (error: any) => any): promise.Promise<R>;
|
||||
|
||||
|
||||
/**
|
||||
* Registers a listener for when this promise is rejected. This is synonymous
|
||||
* with the {@code catch} clause in a synchronous API:
|
||||
* <pre><code>
|
||||
* // Synchronous API:
|
||||
* try {
|
||||
* doSynchronousWork();
|
||||
* } catch (ex) {
|
||||
* console.error(ex);
|
||||
* }
|
||||
*
|
||||
* // Asynchronous promise API:
|
||||
* doAsynchronousWork().thenCatch(function(ex) {
|
||||
* console.error(ex);
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
* @param {function(*): (R|promise.Promise.<R>)} errback The function
|
||||
* to call if this promise is rejected. The function should expect a single
|
||||
* argument: the rejection reason.
|
||||
* @return {!promise.Promise.<R>} A new promise which will be
|
||||
* resolved with the result of the invoked callback.
|
||||
* @template R
|
||||
*/
|
||||
thenCatch<R>(errback: (error: any) => any): promise.Promise<R>;
|
||||
|
||||
|
||||
/**
|
||||
* Registers a listener to invoke when this promise is resolved, regardless
|
||||
* of whether the promise's value was successfully computed. This function
|
||||
* is synonymous with the {@code finally} clause in a synchronous API:
|
||||
* <pre><code>
|
||||
* // Synchronous API:
|
||||
* try {
|
||||
* doSynchronousWork();
|
||||
* } finally {
|
||||
* cleanUp();
|
||||
* }
|
||||
*
|
||||
* // Asynchronous promise API:
|
||||
* doAsynchronousWork().thenFinally(cleanUp);
|
||||
* </code></pre>
|
||||
*
|
||||
* <b>Note:</b> similar to the {@code finally} clause, if the registered
|
||||
* callback returns a rejected promise or throws an error, it will silently
|
||||
* replace the rejection error (if any) from this promise:
|
||||
* <pre><code>
|
||||
* try {
|
||||
* throw Error('one');
|
||||
* } finally {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* }
|
||||
*
|
||||
* promise.rejected(Error('one'))
|
||||
* .thenFinally(function() {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
*
|
||||
* @param {function(): (R|promise.Promise.<R>)} callback The function
|
||||
* to call when this promise is resolved.
|
||||
* @return {!promise.Promise.<R>} A promise that will be fulfilled
|
||||
* with the callback result.
|
||||
* @template R
|
||||
*/
|
||||
thenFinally<R>(callback: () => any): promise.Promise<R>;
|
||||
|
||||
/**
|
||||
* Registers a listener for when this promise is rejected. This is synonymous
|
||||
* with the {@code catch} clause in a synchronous API:
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
import * as chrome from 'selenium-webdriver/chrome';
|
||||
import * as firefox from 'selenium-webdriver/firefox';
|
||||
import * as http from 'selenium-webdriver/http';
|
||||
import * as remote from 'selenium-webdriver/remote';
|
||||
import * as executors from 'selenium-webdriver/executors';
|
||||
import * as testing from 'selenium-webdriver/testing';
|
||||
|
||||
function TestExecutors() {
|
||||
var exec: webdriver.Executor = executors.createExecutor('url');
|
||||
var promise: webdriver.promise.Promise<string>;
|
||||
exec = executors.createExecutor(promise);
|
||||
}
|
||||
|
||||
function TestBuilder() {
|
||||
var builder: webdriver.Builder = new webdriver.Builder();
|
||||
|
||||
@@ -219,11 +213,6 @@ function TestCommand() {
|
||||
command = command.setParameters({ param: 123 });
|
||||
}
|
||||
|
||||
function TestDeferredExecutor() {
|
||||
var promise: webdriver.promise.Promise<webdriver.Executor>;
|
||||
var executor: webdriver.DeferredExecutor = new webdriver.DeferredExecutor(promise);
|
||||
}
|
||||
|
||||
function TestCommandName() {
|
||||
var command: string;
|
||||
|
||||
@@ -469,14 +458,6 @@ function TestSession() {
|
||||
var data: string = session.toJSON();
|
||||
}
|
||||
|
||||
function TestUnhandledAlertError() {
|
||||
var someFunc = (error: webdriver.UnhandledAlertError) => {
|
||||
var baseError: Error = error;
|
||||
var str: string = error.getAlertText();
|
||||
str = error.toString();
|
||||
};
|
||||
}
|
||||
|
||||
function TestWebDriverFileDetector() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
@@ -519,13 +500,21 @@ function TestWebDriverOptions() {
|
||||
var options: webdriver.Options = new webdriver.Options(driver);
|
||||
var promise: webdriver.promise.Promise<void>;
|
||||
|
||||
var name: string = 'name';
|
||||
var value: string = 'value';
|
||||
var path: string = 'path';
|
||||
var domain: string = 'domain';
|
||||
var secure: boolean = true;
|
||||
var httpOnly: boolean = true;
|
||||
|
||||
// Add Cookie
|
||||
promise = options.addCookie('name', 'value');
|
||||
promise = options.addCookie('name', 'value', 'path');
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain');
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain', true);
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain', true, 123);
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain', true, Date.now());
|
||||
promise = options.addCookie({ name, value });
|
||||
promise = options.addCookie({ name, value, path });
|
||||
promise = options.addCookie({ name, value, path, domain });
|
||||
promise = options.addCookie({ name, value, path, domain, secure });
|
||||
promise = options.addCookie({ name, value, path, domain, secure, httpOnly });
|
||||
promise = options.addCookie({ name, value, path, domain, secure, httpOnly, expiry: 123 });
|
||||
promise = options.addCookie({ name, value, path, domain, secure, httpOnly, expiry: Date.now() });
|
||||
|
||||
promise = options.deleteAllCookies();
|
||||
promise = options.deleteCookie('name');
|
||||
@@ -585,7 +574,8 @@ function TestWebDriverWindow() {
|
||||
function TestWebDriver() {
|
||||
var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
|
||||
var sessionPromise: webdriver.promise.Promise<webdriver.Session>;
|
||||
var executor: webdriver.Executor = executors.createExecutor('http://someserver');
|
||||
var httpClient: http.HttpClient = new http.HttpClient('http://someserver');
|
||||
var executor: http.Executor = new http.Executor(httpClient);
|
||||
var flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow();
|
||||
var driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor);
|
||||
driver = new webdriver.WebDriver(session, executor, flow);
|
||||
@@ -638,9 +628,6 @@ function TestWebDriver() {
|
||||
stringPromise = driver.getTitle();
|
||||
stringPromise = driver.getWindowHandle();
|
||||
|
||||
booleanPromise = driver.isElementPresent(webdriver.By.className('ABC'));
|
||||
booleanPromise = driver.isElementPresent(webdriver.By.js('function(){}'));
|
||||
|
||||
var options: webdriver.Options = driver.manage();
|
||||
var navigation: webdriver.Navigation = driver.navigate();
|
||||
var locator: webdriver.TargetLocator = driver.switchTo();
|
||||
@@ -691,14 +678,11 @@ function TestWebElement() {
|
||||
|
||||
element = element.findElement(webdriver.By.id('ABC'));
|
||||
element.findElements(webdriver.By.className('ABC')).then((elements: webdriver.WebElement[]) => {});
|
||||
booleanPromise = element.isElementPresent(webdriver.By.className('ABC'));
|
||||
|
||||
stringPromise = element.getAttribute('class');
|
||||
stringPromise = element.getCssValue('display');
|
||||
driver = element.getDriver();
|
||||
stringPromise = element.getInnerHtml();
|
||||
element.getLocation().then((location: webdriver.ILocation) => {});
|
||||
stringPromise = element.getOuterHtml();
|
||||
element.getSize().then((size: webdriver.ISize) => {});
|
||||
stringPromise = element.getTagName();
|
||||
stringPromise = element.getText();
|
||||
@@ -712,7 +696,6 @@ function TestWebElement() {
|
||||
voidPromise = element.sendKeys('A', 1, webdriver.Key.BACK_SPACE, stringPromise);
|
||||
voidPromise = element.submit();
|
||||
element.getId().then((id: string) => {});
|
||||
element.getRawId().then((id: string) => {});
|
||||
element.serialize().then((id: webdriver.IWebElementId) => {});
|
||||
|
||||
booleanPromise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, 'elementId'));
|
||||
@@ -734,10 +717,6 @@ function TestWebElementPromise() {
|
||||
elementPromise.then((element: webdriver.WebElement) => {});
|
||||
elementPromise.then((element: webdriver.WebElement) => {}, (error: any) => {});
|
||||
elementPromise.then((element: webdriver.WebElement) => 'foo', (error: any) => {}).then((result: string) => {});
|
||||
|
||||
elementPromise.thenCatch((error: any) => {}).then((value: any) => {});
|
||||
|
||||
elementPromise.thenFinally(() => {});
|
||||
}
|
||||
|
||||
function TestLogging() {
|
||||
@@ -963,10 +942,6 @@ function TestPromiseClass() {
|
||||
promise = promise.then((a: string) => 'cde');
|
||||
promise = promise.then((a: string) => 'cde', (e: any) => {});
|
||||
promise = promise.then((a: string) => 'cde', (e: any) => 123);
|
||||
|
||||
promise = promise.thenCatch((error: any) => {});
|
||||
|
||||
promise.thenFinally(() => {});
|
||||
}
|
||||
|
||||
function TestThenableClass() {
|
||||
@@ -981,39 +956,6 @@ function TestThenableClass() {
|
||||
thenable = thenable.then((a: string) => 'cde');
|
||||
thenable = thenable.then((a: string) => 'cde', (e: any) => {});
|
||||
thenable = thenable.then((a: string) => 'cde', (e: any) => 123);
|
||||
|
||||
thenable = thenable.thenCatch((error: any) => {});
|
||||
|
||||
thenable.thenFinally(() => {});
|
||||
}
|
||||
|
||||
function TestErrorCode() {
|
||||
var errorCode: number;
|
||||
|
||||
errorCode = new webdriver.error.ElementNotSelectableError().code();
|
||||
errorCode = new webdriver.error.ElementNotVisibleError().code();
|
||||
errorCode = new webdriver.error.InvalidArgumentError().code();
|
||||
errorCode = new webdriver.error.InvalidCookieDomainError().code();
|
||||
errorCode = new webdriver.error.InvalidElementCoordinatesError().code();
|
||||
errorCode = new webdriver.error.InvalidElementStateError().code();
|
||||
errorCode = new webdriver.error.InvalidSelectorError().code();
|
||||
errorCode = new webdriver.error.NoSuchSessionError().code();
|
||||
errorCode = new webdriver.error.JavascriptError().code();
|
||||
errorCode = new webdriver.error.MoveTargetOutOfBoundsError().code();
|
||||
errorCode = new webdriver.error.NoSuchAlertError().code();
|
||||
errorCode = new webdriver.error.NoSuchElementError().code();
|
||||
errorCode = new webdriver.error.NoSuchFrameError().code();
|
||||
errorCode = new webdriver.error.NoSuchWindowError().code();
|
||||
errorCode = new webdriver.error.ScriptTimeoutError().code();
|
||||
errorCode = new webdriver.error.SessionNotCreatedError().code();
|
||||
errorCode = new webdriver.error.StaleElementReferenceError().code();
|
||||
errorCode = new webdriver.error.TimeoutError().code();
|
||||
errorCode = new webdriver.error.UnableToSetCookieError().code();
|
||||
errorCode = new webdriver.error.UnableToCaptureScreenError().code();
|
||||
errorCode = new webdriver.error.UnexpectedAlertOpenError().code();
|
||||
errorCode = new webdriver.error.UnknownCommandError().code();
|
||||
errorCode = new webdriver.error.UnknownMethodError().code();
|
||||
errorCode = new webdriver.error.UnsupportedOperationError().code();
|
||||
}
|
||||
|
||||
async function TestAsyncAwaitable() {
|
||||
|
||||
Reference in New Issue
Block a user