diff --git a/types/selenium-webdriver/edge.d.ts b/types/selenium-webdriver/edge.d.ts index 508c997219..0673f534df 100644 --- a/types/selenium-webdriver/edge.d.ts +++ b/types/selenium-webdriver/edge.d.ts @@ -25,23 +25,7 @@ export class Driver extends webdriver.WebDriver { /** * Class for managing MicrosoftEdgeDriver specific options. */ -export class Options extends webdriver.Capabilities { - /** - * Sets the proxy settings for the new session. - * @param {capabilities.ProxyConfig} proxy The proxy configuration to use. - * @return {!Options} A self reference. - */ - setProxy(proxy: webdriver.ProxyConfig): Options; - - /** - * Sets the page load strategy for Edge. - * Supported values are 'normal', 'eager', and 'none'; - * - * @param {string} pageLoadStrategy The page load strategy to use. - * @return {!Options} A self reference. - */ - setPageLoadStrategy(pageLoadStrategy: string): Options; -} +export class Options extends webdriver.Capabilities {} /** * Creates {@link remote.DriverService} instances that manage a diff --git a/types/selenium-webdriver/index.d.ts b/types/selenium-webdriver/index.d.ts index 2728c70bae..f3cf4c9b14 100644 --- a/types/selenium-webdriver/index.d.ts +++ b/types/selenium-webdriver/index.d.ts @@ -17,6 +17,7 @@ import * as edge from './edge'; import * as firefox from './firefox'; import * as ie from './ie'; import { By, ByHash } from './lib/by'; +import { Browser, Capability, Capabilities, ITimeouts } from './lib/capabilities'; import * as command from './lib/command'; import * as http from './http'; import { Actions, Button, Key, Origin } from './lib/input'; @@ -25,6 +26,7 @@ import * as until from './lib/until'; import * as safari from './safari'; export { By, ByHash } from './lib/by'; +export { Browser, Capability, Capabilities, ITimeouts } from './lib/capabilities'; export { Actions, Button, Key, Origin } from './lib/input'; export { promise } from './lib/promise'; export { until as until }; @@ -922,30 +924,6 @@ export class AlertPromise extends Alert { constructor(driver: WebDriver, alert: Promise); } -/** - * Recognized browser names. - * @enum {string} - */ -export interface IBrowser { - ANDROID: string; - CHROME: string; - EDGE: string; - FIREFOX: string; - IE: string; - INTERNET_EXPLORER: string; - IPAD: string; - IPHONE: string; - OPERA: string; - PHANTOM_JS: string; - SAFARI: string; - HTMLUNIT: string; -} - -/** - * Instace of - */ -export const Browser: IBrowser; - /** * ProxyConfig */ @@ -1260,280 +1238,6 @@ export class Builder { export type Locator = By | Function | ByHash; -/** - * Common webdriver capability keys. - * @enum {string} - */ -export interface ICapability { - /** - * Indicates whether a driver should accept all SSL certs by default. This - * capability only applies when requesting a new session. To query whether - * a driver can handle insecure SSL certs, see - * {@link Capability.SECURE_SSL}. - */ - ACCEPT_SSL_CERTS: string; - - /** - * The browser name. Common browser names are defined in the - * {@link Browser} enum. - */ - BROWSER_NAME: string; - - /** - * Defines how elements should be scrolled into the viewport for interaction. - * This capability will be set to zero (0) if elements are aligned with the - * top of the viewport, or one (1) if aligned with the bottom. The default - * behavior is to align with the top of the viewport. - */ - ELEMENT_SCROLL_BEHAVIOR: string; - - /** - * Whether the driver is capable of handling modal alerts (e.g. alert, - * confirm, prompt). To define how a driver should handle alerts, - * use {@link Capability.UNEXPECTED_ALERT_BEHAVIOR}. - */ - HANDLES_ALERTS: string; - - /** - * Key for the logging driver logging preferences. - */ - LOGGING_PREFS: string; - - /** - * Whether this session generates native events when simulating user input. - */ - NATIVE_EVENTS: string; - - /** - * Describes the platform the browser is running on. Will be one of - * ANDROID, IOS, LINUX, MAC, UNIX, or WINDOWS. When requesting a - * session, ANY may be used to indicate no platform preference (this is - * semantically equivalent to omitting the platform capability). - */ - PLATFORM: string; - - /** - * Describes the proxy configuration to use for a new WebDriver session. - */ - PROXY: string; - - /** Whether the driver supports changing the brower's orientation. */ - ROTATABLE: string; - - /** - * Whether a driver is only capable of handling secure SSL certs. To request - * that a driver accept insecure SSL certs by default, use - * {@link Capability.ACCEPT_SSL_CERTS}. - */ - SECURE_SSL: string; - - /** Whether the driver supports manipulating the app cache. */ - SUPPORTS_APPLICATION_CACHE: string; - - /** Whether the driver supports locating elements with CSS selectors. */ - SUPPORTS_CSS_SELECTORS: string; - - /** Whether the browser supports JavaScript. */ - SUPPORTS_JAVASCRIPT: string; - - /** Whether the driver supports controlling the browser's location info. */ - SUPPORTS_LOCATION_CONTEXT: string; - - /** Whether the driver supports taking screenshots. */ - TAKES_SCREENSHOT: string; - - /** - * Defines how the driver should handle unexpected alerts. The value should - * be one of 'accept', 'dismiss', or 'ignore. - */ - UNEXPECTED_ALERT_BEHAVIOR: string; - - /** Defines the browser version. */ - VERSION: string; -} - -/** - * The standard WebDriver capability keys. - */ -export const Capability: ICapability; - -/** - * Describes a set of capabilities for a WebDriver session. - */ -export class Capabilities { - // region Constructors - - /** - * @param {(Capabilities|Object)=} opt_other Another set of - * capabilities to merge into this instance. - * @constructor - */ - constructor(opt_other?: Capabilities|{}); - - // endregion - - // region Methods - - /** @return {!Object} The JSON representation of this instance. */ - toJSON(): any; - - /** - * Merges another set of capabilities into this instance. Any duplicates in - * the provided set will override those already set on this instance. - * @param {!(Capabilities|Object)} other The capabilities to - * merge into this instance. - * @return {!Capabilities} A self reference. - */ - merge(other: Capabilities|{}): Capabilities; - - /** - * @param {string} key The capability to set. - * @param {*} value The capability value. Capability values must be JSON - * serializable. Pass {@code null} to unset the capability. - * @return {!Capabilities} A self reference. - */ - set(key: string, value: any): Capabilities; - - /** - * Sets the name of the target browser. - * - * @param {(Browser|string)} name the browser name. - * @return {!Capabilities} a self reference. - */ - setBrowserName(name: string): Capabilities; - - /** - * Sets the desired version of the target browser. - * - * @param {string} version the desired version. - * @return {!Capabilities} a self reference. - */ - setBrowserVersion(version: string): Capabilities; - - /** - * Sets the logging preferences. Preferences may be specified as a - * {@link logging.Preferences} instance, or a as a map of log-type to - * log-level. - * @param {!(logging.Preferences|Object.)} prefs The - * logging preferences. - * @return {!Capabilities} A self reference. - */ - setLoggingPrefs(prefs: logging.Preferences|{}): Capabilities; - - /** - * Sets the proxy configuration for this instance. - * @param {ProxyConfig} proxy The desired proxy configuration. - * @return {!Capabilities} A self reference. - */ - setProxy(proxy: ProxyConfig): Capabilities; - - /** - * Sets whether native events should be used. - * @param {boolean} enabled Whether to enable native events. - * @return {!Capabilities} A self reference. - */ - setEnableNativeEvents(enabled: boolean): Capabilities; - - /** - * Sets how elements should be scrolled into view for interaction. - * @param {number} behavior The desired scroll behavior: either 0 to align - * with the top of the viewport or 1 to align with the bottom. - * @return {!Capabilities} A self reference. - */ - setScrollBehavior(behavior: number): Capabilities; - - /** - * Sets the default action to take with an unexpected alert before returning - * an error. - * @param {string} behavior The desired behavior; should be 'accept', - * 'dismiss', or 'ignore'. Defaults to 'dismiss'. - * @return {!Capabilities} A self reference. - */ - setAlertBehavior(behavior?: string): Capabilities; - - /** - * @param {string} key The capability to return. - * @return {*} The capability with the given key, or {@code null} if it has - * not been set. - */ - get(key: string): any; - - /** - * @param {string} key The capability to check. - * @return {boolean} Whether the specified capability is set. - */ - has(key: string): boolean; - - // endregion - - // region Static Methods - - /** - * @return {!Capabilities} A basic set of capabilities for Android. - */ - static android(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for Chrome. - */ - static chrome(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for Microsoft Edge. - */ - static edge(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for Firefox. - */ - static firefox(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for - * Internet Explorer. - */ - static ie(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for iPad. - */ - static ipad(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for iPhone. - */ - static iphone(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for Opera. - */ - static opera(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for - * PhantomJS. - */ - static phantomjs(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for Safari. - */ - static safari(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for HTMLUnit. - */ - static htmlunit(): Capabilities; - - /** - * @return {!Capabilities} A basic set of capabilities for HTMLUnit - * with enabled Javascript. - */ - static htmlunitwithjs(): Capabilities; - - // endregion -} - /** * Describes an event listener registered on an {@linkplain EventEmitter}. */ @@ -1837,39 +1541,6 @@ export class Options { // endregion } -interface ITimeouts { - /** - * Sets the amount of time to wait, in milliseconds, for an asynchronous - * script to finish execution before returning an error. If the timeout is - * less than or equal to 0, the script will be allowed to run indefinitely. - */ - script?: number; - /** - * Sets the amount of time to wait, in milliseconds, for a page load to - * complete before returning an error. If the timeout is negative, - * page loads may be indefinite. - */ - pageLoad?: number; - /** - * Specifies the amount of time in milliseconds the driver should wait when - * searching for an element if it is not immediately present. - *

- * When searching for a single element, the driver should poll the page - * until the element has been found, or this timeout expires before failing - * with a {@code bot.ErrorCode.NO_SUCH_ELEMENT} error. When searching - * for multiple elements, the driver should poll the page until at least one - * element has been found or this timeout has expired. - *

- * Setting the wait timeout to 0 (its default value), disables implicit - * waiting. - *

- * Increasing the implicit wait timeout should be used judiciously as it - * will have an adverse effect on test run time, especially when used with - * slower location strategies like XPath. - */ - implicit?: number; -} - /** * An interface for managing the current window. */ diff --git a/types/selenium-webdriver/lib/capabilities.d.ts b/types/selenium-webdriver/lib/capabilities.d.ts new file mode 100644 index 0000000000..7dedb4df20 --- /dev/null +++ b/types/selenium-webdriver/lib/capabilities.d.ts @@ -0,0 +1,397 @@ +import Symbols from './symbols'; +import { logging, ProxyConfig } from '../'; + +/** + * Recognized browser names. + * @enum {string} + */ +export interface IBrowser { + CHROME: string; + EDGE: string; + FIREFOX: string; + IE: string; + INTERNET_EXPLORER: string; + SAFARI: string; +} + +/** + * Instace of + */ +export const Browser: IBrowser; + +/** + * Common platform names. These platforms are not explicitly defined by the + * WebDriver spec, however, their use is encouraged for interoperability. + * + * @enum {string} + * @see + */ +export interface IPlatform { + LINUX: string; + MAC: string; + WINDOWS: string; +} + +export const Platform: IPlatform; + +/** + * Strategies for waiting for [document readiness] after a navigation event. + * + * [document readiness]: https://html.spec.whatwg.org/#current-document-readiness + * + * @enum {string} + */ +export interface IPageLoadStrategy { + /** + * Indicates WebDriver should not wait on the document readiness state after a + * navigation event. + */ + NONE: string; + + /** + * Indicates WebDriver should wait for the document readiness state to + * become "interactive" after navigation. + */ + EAGER: string; + + /** + * Indicates WebDriver should wait for the document readiness state to + * be "complete" after navigation. This is the default page loading strategy. + */ + NORMAL: string; +} + +export const PageLoadStrategy: IPageLoadStrategy; + +/** + * The possible default actions a WebDriver session can take to respond to + * unhandled user prompts (`window.alert()`, `window.confirm()`, and + * `window.prompt()`). + * + * @enum {string} + */ +export interface IUserPromptHandler { + /** All prompts should be silently accepted. */ + ACCEPT: string; + /** All prompts should be silently dismissed. */ + DISMISS: string; + /** + * All prompts should be automatically accepted, but an error should be + * returned to the next (or currently executing) WebDriver command. + */ + ACCEPT_AND_NOTIFY: string; + /** + * All prompts should be automatically dismissed, but an error should be + * returned to the next (or currently executing) WebDriver command. + */ + DISMISS_AND_NOTIFY: string; + /** All prompts should be left unhandled. */ + IGNORE: string; +} + +export const UserPromptHandler: IUserPromptHandler; + +/** + * Common webdriver capability keys. + * @enum {string} + */ +export interface ICapability { + /** + * Indicates whether a WebDriver session implicitly trusts otherwise untrusted + * and self-signed TLS certificates during navigation. + */ + ACCEPT_INSECURE_TLS_CERTS: string; + + /** + * The browser name. Common browser names are defined in the + * {@link ./capabilities.Browser Browser} enum. + */ + BROWSER_NAME: string; + + /** Identifies the browser version. */ + BROWSER_VERSION: string; + + /** + * Key for the logging driver logging preferences. + */ + LOGGING_PREFS: string; + + /** + * Defines the session's + * {@linkplain ./capabilities.PageLoadStrategy page loading strategy}. + */ + PAGE_LOAD_STRATEGY: string; + + /** + * Identifies the operating system of the endpoint node. Common values + * recognized by the most WebDriver server implementations are predefined in + * the {@link ./capabilities.Platform Platform} enum. + */ + PLATFORM_NAME: string; + + /** + * Describes the proxy configuration to use for a new WebDriver session. + */ + PROXY: string; + + /** + * Indicates whether the remote end supports all of the window resizing and + * positioning commands: + * + * - {@linkplain ./webdriver.Window#getRect Window.getRect()} + * - {@linkplain ./webdriver.Window#setRect Window.setRect()} + * - {@linkplain ./webdriver.Window#maximize Window.maximize()} + * - {@linkplain ./webdriver.Window#minimize Window.minimize()} + * - {@linkplain ./webdriver.Window#fullscreen Window.fullscreen()} + */ + SET_WINDOW_RECT: string; + + /** + * Describes the {@linkplain ./capabilities.Timeouts timeouts} imposed on + * certain session operations. + */ + TIMEOUTS: string; + + /** + * Defines how a WebDriver session should + * {@linkplain ./capabilities.UserPromptHandler respond} to unhandled user + * prompts. + */ + UNHANDLED_PROMPT_BEHAVIOR: string; +} + +/** + * The standard WebDriver capability keys. + */ +export const Capability: ICapability; + +/** + * Describes a set of capabilities for a WebDriver session. + */ +export class Capabilities { + // region Constructors + + /** + * @param {(Capabilities|Map|Object)=} other Another set of + * capabilities to initialize this instance from. + */ + constructor(other?: Capabilities|Map|{}); + + // endregion + + // region Static Methods + + /** + * @return {!Capabilities} A basic set of capabilities for Chrome. + */ + static chrome(): Capabilities; + + /** + * @return {!Capabilities} A basic set of capabilities for Microsoft Edge. + */ + static edge(): Capabilities; + + /** + * @return {!Capabilities} A basic set of capabilities for Firefox. + */ + static firefox(): Capabilities; + + /** + * @return {!Capabilities} A basic set of capabilities for + * Internet Explorer. + */ + static ie(): Capabilities; + + /** + * @return {!Capabilities} A basic set of capabilities for Safari. + */ + static safari(): Capabilities; + + // endregion + + // region Methods + + /** + * @return {!Object} The JSON representation of this instance. + * Note, the returned object may contain nested promised values. + * @suppress {checkTypes} Suppress [] access on a struct (state inherited from + * Map). + */ + [Symbols.serialize](): {} + + /** + * @param {string} key The capability to return. + * @return {*} The capability with the given key, or {@code null} if it has + * not been set. + */ + get(key: string): any; + + /** + * @param {string} key The capability to check. + * @return {boolean} Whether the specified capability is set. + */ + has(key: string): boolean; + + /** + * @return {!Iterator} an iterator of the keys set. + */ + keys(): IterableIterator; + + /** + * Merges another set of capabilities into this instance. + * @param {!(Capabilities|Map|Object)} other The other + * set of capabilities to merge. + * @return {!Capabilities} A self reference. + */ + merge(other: Capabilities|Map|{}): Capabilities; + + /** + * Deletes an entry from this set of capabilities. + * + * @param {string} key the capability key to delete. + */ + delete(key: string): boolean; + + /** + * @param {string} key The capability key. + * @param {*} value The capability value. + * @return {!Capabilities} A self reference. + * @throws {TypeError} If the `key` is not a string. + */ + set(key: string, value: any): Capabilities; + + /** + * Sets whether a WebDriver session should implicitly accept self-signed, or + * other untrusted TLS certificates on navigation. + * + * @param {boolean} accept whether to accept insecure certs. + * @return {!Capabilities} a self reference. + */ + setAcceptInsecureCerts(accept: boolean): Capabilities; + + /** + * @return {boolean} whether the session is configured to accept insecure + * TLS certificates. + */ + getAcceptInsecureCerts(): boolean; + + /** + * Sets the name of the target browser. + * + * @param {(Browser|string)} name the browser name. + * @return {!Capabilities} a self reference. + */ + setBrowserName(name: string): Capabilities; + + /** + * @return {(string|undefined)} the configured browser name, or undefined if + * not set. + */ + getBrowserName(): string|undefined; + + /** + * Sets the desired version of the target browser. + * + * @param {string} version the desired version. + * @return {!Capabilities} a self reference. + */ + setBrowserVersion(version: string): Capabilities; + + /** + * @return {(string|undefined)} the configured browser version, or undefined + * if not set. + */ + getBrowserVersion(): string|undefined; + + /** + * Sets the desired page loading strategy for a new WebDriver session. + * + * @param {PageLoadStrategy} strategy the desired strategy. + * @return {!Capabilities} a self reference. + */ + setPageLoadStrategy(strategy: string): Capabilities; + + /** + * Returns the configured page load strategy. + * + * @return {(string|undefined)} the page load strategy. + */ + getPageLoadStrategy(): string|undefined; + + /** + * Sets the target platform. + * + * @param {(Platform|string)} platform the target platform. + * @return {!Capabilities} a self reference. + */ + setPlatform(platform: string): Capabilities; + + /** + * @return {(string|undefined)} the configured platform or undefined if not + * set. + */ + getPlatform(): string|undefined; + + /** + * Sets the logging preferences. Preferences may be specified as a + * {@link ./logging.Preferences} instance, or as a map of log-type to + * log-level. + * @param {!(./logging.Preferences|Object)} prefs The logging + * preferences. + * @return {!Capabilities} A self reference. + */ + setLoggingPrefs(prefs: logging.Preferences|{}): Capabilities; + + /** + * Sets the proxy configuration for this instance. + * @param {proxy.Config} proxy The desired proxy configuration. + * @return {!Capabilities} A self reference. + */ + setProxy(proxy: ProxyConfig): Capabilities; + + /** + * @return {(proxy.Config|undefined)} the configured proxy settings, or + * undefined if not set. + */ + getProxy(): ProxyConfig|undefined; + + /** + * Sets the default action to take with an unexpected alert before returning + * an error. If unspecified, WebDriver will default to + * {@link UserPromptHandler.DISMISS_AND_NOTIFY}. + * + * @param {?UserPromptHandler} behavior The way WebDriver should respond to + * unhandled user prompts. + * @return {!Capabilities} A self reference. + */ + setAlertBehavior(behavior: string): Capabilities; + + /** + * @return {(UserPromptHandler|undefined)} the behavior pattern for responding + * to unhandled user prompts, or undefined if not set. + */ + getAlertBehavior(): string|undefined; + + // endregion +} + +export interface ITimeouts { + /** + * Defines when, in milliseconds, to interrupt a script that is being + * {@linkplain ./webdriver.IWebDriver#executeScript evaluated}. + */ + script?: number; + + /** + * The timeout, in milliseconds, to apply to navigation events along with the + * {@link PageLoadStrategy}. + */ + pageLoad?: number; + + /** + * The maximum amount of time, in milliseconds, to spend attempting to + * {@linkplain ./webdriver.IWebDriver#findElement locate} an element on the + * current page. + */ + implicit?: number; +} diff --git a/types/selenium-webdriver/lib/symbols.d.ts b/types/selenium-webdriver/lib/symbols.d.ts new file mode 100644 index 0000000000..d984b7587a --- /dev/null +++ b/types/selenium-webdriver/lib/symbols.d.ts @@ -0,0 +1,16 @@ +export interface ISymbols { + /** + * The serialize symbol specifies a method that returns an object's serialized + * representation. If an object's serialized form is not immediately + * available, the serialize method will return a promise that will be resolved + * with the serialized form. + * + * Note that the described method is analogous to objects that define a + * `toJSON()` method, except the serialized result may be a promise, or + * another object with a promised property. + */ + readonly serialize: unique symbol; +} + +declare const Symbols: ISymbols; +export default Symbols; diff --git a/types/selenium-webdriver/safari.d.ts b/types/selenium-webdriver/safari.d.ts index eee4e567fb..933bcae786 100644 --- a/types/selenium-webdriver/safari.d.ts +++ b/types/selenium-webdriver/safari.d.ts @@ -35,11 +35,13 @@ export class CommandExecutor {} */ export class Options extends webdriver.Capabilities { /** - * Sets the logging preferences for the new session. - * @param {!./lib/logging.Preferences} prefs The logging preferences. + * Instruct the SafariDriver to use the Safari Technology Preview if true. + * Otherwise, use the release version of Safari. Defaults to using the release version of Safari. + * + * @param {boolean} useTechnologyPreview * @return {!Options} A self reference. */ - setLoggingPrefs(prefs: webdriver.logging.Preferences): Options; + setTechnologyPreview(useTechnologyPreview: boolean): Options; } /** diff --git a/types/selenium-webdriver/test/index.ts b/types/selenium-webdriver/test/index.ts index 7223a4ae5f..9e7cf06cfa 100644 --- a/types/selenium-webdriver/test/index.ts +++ b/types/selenium-webdriver/test/index.ts @@ -5,7 +5,9 @@ import * as firefox from 'selenium-webdriver/firefox'; import * as http from 'selenium-webdriver/http'; import * as ie from 'selenium-webdriver/ie'; import * as safari from 'selenium-webdriver/safari'; +import { PageLoadStrategy, UserPromptHandler, Platform } from 'selenium-webdriver/lib/capabilities'; import { Command } from 'selenium-webdriver/lib/command'; +import Symbols from 'selenium-webdriver/lib/symbols'; function TestBuilder() { let builder: webdriver.Builder = new webdriver.Builder(); @@ -80,15 +82,11 @@ function TestAlert() { function TestBrowser() { let browser: string; - browser = webdriver.Browser.ANDROID; browser = webdriver.Browser.CHROME; + browser = webdriver.Browser.EDGE; browser = webdriver.Browser.FIREFOX; - browser = webdriver.Browser.HTMLUNIT; + browser = webdriver.Browser.IE; browser = webdriver.Browser.INTERNET_EXPLORER; - browser = webdriver.Browser.IPAD; - browser = webdriver.Browser.IPHONE; - browser = webdriver.Browser.OPERA; - browser = webdriver.Browser.PHANTOM_JS; browser = webdriver.Browser.SAFARI; } @@ -96,61 +94,46 @@ function TestCapabilities() { let capabilities: webdriver.Capabilities = new webdriver.Capabilities(); capabilities = new webdriver.Capabilities(webdriver.Capabilities.chrome()); let objCapabilities: any = {}; - objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.PHANTOM_JS; + objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.SAFARI; capabilities = new webdriver.Capabilities(objCapabilities); - let anything: any = capabilities.get(webdriver.Capability.SECURE_SSL); - let check: boolean = capabilities.has(webdriver.Capability.SECURE_SSL); + let anything: any = capabilities.get(webdriver.Capability.ACCEPT_INSECURE_TLS_CERTS); + let check: boolean = capabilities.has(webdriver.Capability.ACCEPT_INSECURE_TLS_CERTS); capabilities = capabilities.merge(capabilities); capabilities = capabilities.merge(objCapabilities); - capabilities = capabilities.set(webdriver.Capability.VERSION, { abc: 'def' }); - capabilities = capabilities.set(webdriver.Capability.VERSION, null); + capabilities = capabilities.set(webdriver.Capability.BROWSER_VERSION, { abc: 'def' }); + capabilities = capabilities.set(webdriver.Capability.BROWSER_VERSION, null); capabilities = capabilities.setLoggingPrefs(new webdriver.logging.Preferences()); capabilities = capabilities.setLoggingPrefs({ key: 'value' }); capabilities = capabilities.setProxy({ proxyType: 'Type' }); - capabilities = capabilities.setEnableNativeEvents(true); - capabilities = capabilities.setScrollBehavior(1); - capabilities = capabilities.setAlertBehavior('accept'); - capabilities = capabilities.setAlertBehavior(); + capabilities = capabilities.setPageLoadStrategy(PageLoadStrategy.NORMAL); + capabilities = capabilities.setAlertBehavior(UserPromptHandler.ACCEPT); capabilities = capabilities.setBrowserName('myBrowserName'); - capabilities = capabilities.setBrowserName(webdriver.Browser.ANDROID); + capabilities = capabilities.setBrowserName(webdriver.Browser.SAFARI); capabilities = capabilities.setBrowserVersion('10.3.4'); - anything = capabilities.toJSON(); + anything = capabilities[Symbols.serialize](); - capabilities = webdriver.Capabilities.android(); capabilities = webdriver.Capabilities.chrome(); + capabilities = webdriver.Capabilities.edge(); capabilities = webdriver.Capabilities.firefox(); - capabilities = webdriver.Capabilities.htmlunit(); - capabilities = webdriver.Capabilities.htmlunitwithjs(); capabilities = webdriver.Capabilities.ie(); - capabilities = webdriver.Capabilities.ipad(); - capabilities = webdriver.Capabilities.iphone(); - capabilities = webdriver.Capabilities.opera(); - capabilities = webdriver.Capabilities.phantomjs(); capabilities = webdriver.Capabilities.safari(); } function TestCapability() { let capability: string; - capability = webdriver.Capability.ACCEPT_SSL_CERTS; + capability = webdriver.Capability.ACCEPT_INSECURE_TLS_CERTS; capability = webdriver.Capability.BROWSER_NAME; - capability = webdriver.Capability.ELEMENT_SCROLL_BEHAVIOR; - capability = webdriver.Capability.HANDLES_ALERTS; + capability = webdriver.Capability.BROWSER_VERSION; capability = webdriver.Capability.LOGGING_PREFS; - capability = webdriver.Capability.NATIVE_EVENTS; - capability = webdriver.Capability.PLATFORM; + capability = webdriver.Capability.PLATFORM_NAME; + capability = webdriver.Capability.PAGE_LOAD_STRATEGY; capability = webdriver.Capability.PROXY; - capability = webdriver.Capability.ROTATABLE; - capability = webdriver.Capability.SECURE_SSL; - capability = webdriver.Capability.SUPPORTS_APPLICATION_CACHE; - capability = webdriver.Capability.SUPPORTS_CSS_SELECTORS; - capability = webdriver.Capability.SUPPORTS_JAVASCRIPT; - capability = webdriver.Capability.SUPPORTS_LOCATION_CONTEXT; - capability = webdriver.Capability.TAKES_SCREENSHOT; - capability = webdriver.Capability.UNEXPECTED_ALERT_BEHAVIOR; - capability = webdriver.Capability.VERSION; + capability = webdriver.Capability.SET_WINDOW_RECT; + capability = webdriver.Capability.TIMEOUTS; + capability = webdriver.Capability.UNHANDLED_PROMPT_BEHAVIOR; } function TestEventEmitter() { @@ -285,10 +268,10 @@ function TestBy() { } function TestSession() { - let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android()); + let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.chrome()); let capabilitiesObj: any = {}; - capabilitiesObj[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.ANDROID; - capabilitiesObj[webdriver.Capability.PLATFORM] = 'ANDROID'; + capabilitiesObj[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.CHROME; + capabilitiesObj[webdriver.Capability.PLATFORM_NAME] = Platform.LINUX; session = new webdriver.Session('ABC', capabilitiesObj); let capabilities: webdriver.Capabilities = session.getCapabilities(); @@ -404,7 +387,7 @@ declare const booleanCondition: webdriver.Condition; declare const webElementCondition: webdriver.WebElementCondition; function TestWebDriver() { - let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android()); + let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.chrome()); let httpClient: http.HttpClient = new http.HttpClient('http://someserver'); let executor: http.Executor = new http.Executor(httpClient); let driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor); @@ -475,7 +458,7 @@ function TestWebDriver() { webElementPromise = driver.wait(webElementCondition); voidPromise = driver.wait(webElementCondition).click(); - driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android()); + driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.chrome()); } declare const serializable: webdriver.Serializable;