mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
chore(selenium): update to selenium-webdriver 4 typings
- Update typings and tests - control flow and promise.Promise deprecated - API changes with regard to W3C - Moved previous typings to selenium-webdriver v3 - Set protractor-helpers to use selenium-webdriver v3
This commit is contained in:
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/dequelabs/axe-webdriverjs#readme
|
||||
// Definitions by: Joshua Goldberg <https://github.com/JoshuaKGoldberg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
import { Result, RunOptions, Spec } from "axe-core";
|
||||
import { WebDriver } from "selenium-webdriver";
|
||||
|
||||
@@ -13,6 +13,14 @@
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"selenium-webdriver": [
|
||||
"selenium-webdriver/v3"
|
||||
],
|
||||
"selenium-webdriver/*": [
|
||||
"selenium-webdriver/v3/*"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"selenium-webdriver": [
|
||||
"selenium-webdriver/v3"
|
||||
],
|
||||
"selenium-webdriver/*": [
|
||||
"selenium-webdriver/v3/*"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
|
||||
Vendored
+283
-295
@@ -1,6 +1,6 @@
|
||||
import * as http from './http';
|
||||
import * as webdriver from './index';
|
||||
import * as remote from './remote';
|
||||
import * as http from './http';
|
||||
|
||||
/**
|
||||
* Creates a new WebDriver client for Chrome.
|
||||
@@ -8,294 +8,282 @@ import * as http from './http';
|
||||
* @extends {webdriver.WebDriver}
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new session with the ChromeDriver.
|
||||
*
|
||||
* @param {(Capabilities|Options)=} opt_config The configuration options.
|
||||
* @param {(remote.DriverService|http.Executor)=} opt_serviceExecutor Either
|
||||
* a DriverService to use for the remote end, or a preconfigured executor
|
||||
* for an externally managed endpoint. If neither is provided, the
|
||||
* {@linkplain ##getDefaultService default service} will be used by
|
||||
* default.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to use, or `null`
|
||||
* to use the currently active flow.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: Options | webdriver.CreateSessionCapabilities, opt_service?: remote.DriverService | http.Executor, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
/**
|
||||
* Creates a new session with the ChromeDriver.
|
||||
*
|
||||
* @param {(Capabilities|Options)=} opt_config The configuration options.
|
||||
* @param {(remote.DriverService|http.Executor)=} opt_serviceExecutor Either
|
||||
* a DriverService to use for the remote end, or a preconfigured executor
|
||||
* for an externally managed endpoint. If neither is provided, the
|
||||
* {@linkplain ##getDefaultService default service} will be used by
|
||||
* default.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(
|
||||
opt_config?: Options|webdriver.CreateSessionCapabilities,
|
||||
opt_service?: remote.DriverService|http.Executor): Driver;
|
||||
}
|
||||
|
||||
export interface IOptionsValues {
|
||||
args: string[];
|
||||
binary?: string;
|
||||
detach: boolean;
|
||||
extensions: string[];
|
||||
localState?: any;
|
||||
logFile?: string;
|
||||
prefs?: any;
|
||||
args: string[];
|
||||
binary?: string;
|
||||
detach: boolean;
|
||||
extensions: string[];
|
||||
localState?: any;
|
||||
logFile?: string;
|
||||
prefs?: any;
|
||||
}
|
||||
|
||||
export interface IPerfLoggingPrefs {
|
||||
enableNetwork: boolean;
|
||||
enablePage: boolean;
|
||||
enableTimeline: boolean;
|
||||
tracingCategories: string;
|
||||
bufferUsageReportingInterval: number;
|
||||
enableNetwork: boolean;
|
||||
enablePage: boolean;
|
||||
enableTimeline: boolean;
|
||||
tracingCategories: string;
|
||||
bufferUsageReportingInterval: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for managing ChromeDriver specific options.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
constructor();
|
||||
export class Options extends webdriver.Capabilities {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Extracts the ChromeDriver specific options from the given capabilities
|
||||
* object.
|
||||
* @param {!webdriver.Capabilities} capabilities The capabilities object.
|
||||
* @return {!Options} The ChromeDriver options.
|
||||
*/
|
||||
static fromCapabilities(capabilities: webdriver.Capabilities): Options;
|
||||
/**
|
||||
* Extracts the ChromeDriver specific options from the given capabilities
|
||||
* object.
|
||||
* @param {!webdriver.Capabilities} capabilities The capabilities object.
|
||||
* @return {!Options} The ChromeDriver options.
|
||||
*/
|
||||
static fromCapabilities(capabilities: webdriver.Capabilities): Options;
|
||||
|
||||
/**
|
||||
* Add additional command line arguments to use when launching the Chrome
|
||||
* browser. Each argument may be specified with or without the '--' prefix
|
||||
* (e.g. '--foo' and 'foo'). Arguments with an associated value should be
|
||||
* delimited by an '=': 'foo=bar'.
|
||||
* @param {...(string|!Array.<string>)} var_args The arguments to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...var_args: string[]): Options;
|
||||
/**
|
||||
* Add additional command line arguments to use when launching the Chrome
|
||||
* browser. Each argument may be specified with or without the '--' prefix
|
||||
* (e.g. '--foo' and 'foo'). Arguments with an associated value should be
|
||||
* delimited by an '=': 'foo=bar'.
|
||||
* @param {...(string|!Array.<string>)} var_args The arguments to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...var_args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Configures the chromedriver to start Chrome in headless mode.
|
||||
*
|
||||
* > __NOTE:__ Resizing the browser window in headless mode is only supported
|
||||
* > in Chrome 60. Users are encouraged to set an initial window size with
|
||||
* > the {@link #windowSize windowSize({width, height})} option.
|
||||
*
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
headless(): Options;
|
||||
/**
|
||||
* Configures the chromedriver to start Chrome in headless mode.
|
||||
*
|
||||
* > __NOTE:__ Resizing the browser window in headless mode is only supported
|
||||
* > in Chrome 60. Users are encouraged to set an initial window size with
|
||||
* > the {@link #windowSize windowSize({width, height})} option.
|
||||
*
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
headless(): Options;
|
||||
|
||||
/**
|
||||
* List of Chrome command line switches to exclude that ChromeDriver by default
|
||||
* passes when starting Chrome. Do not prefix switches with '--'.
|
||||
*
|
||||
* @param {...(string|!Array<string>)} var_args The switches to exclude.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
excludeSwitches(...var_args: string[]): Options;
|
||||
/**
|
||||
* Sets the initial window size.
|
||||
*
|
||||
* @param {{width: number, height: number}} size The desired window size.
|
||||
* @return {!Options} A self reference.
|
||||
* @throws {TypeError} if width or height is unspecified, not a number, or
|
||||
* less than or equal to 0.
|
||||
*/
|
||||
windowSize(size: {width: number, height: number}): Options;
|
||||
|
||||
/**
|
||||
* Add additional extensions to install when launching Chrome. Each extension
|
||||
* should be specified as the path to the packed CRX file, or a Buffer for an
|
||||
* extension.
|
||||
* @param {...(string|!Buffer|!Array.<(string|!Buffer)>)} var_args The
|
||||
* extensions to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addExtensions(...var_args: any[]): Options;
|
||||
/**
|
||||
* List of Chrome command line switches to exclude that ChromeDriver by
|
||||
* default passes when starting Chrome. Do not prefix switches with '--'.
|
||||
*
|
||||
* @param {...(string|!Array<string>)} var_args The switches to exclude.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
excludeSwitches(...var_args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Sets the path to the Chrome binary to use. On Mac OS X, this path should
|
||||
* reference the actual Chrome executable, not just the application binary
|
||||
* (e.g. '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome').
|
||||
*
|
||||
* The binary path be absolute or relative to the chromedriver server
|
||||
* executable, but it must exist on the machine that will launch Chrome.
|
||||
*
|
||||
* @param {string} path The path to the Chrome binary to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeBinaryPath(path: string): Options;
|
||||
/**
|
||||
* Add additional extensions to install when launching Chrome. Each extension
|
||||
* should be specified as the path to the packed CRX file, or a Buffer for an
|
||||
* extension.
|
||||
* @param {...(string|!Buffer|!Array.<(string|!Buffer)>)} var_args The
|
||||
* extensions to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addExtensions(...var_args: any[]): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to leave the started Chrome browser running if the controlling
|
||||
* ChromeDriver service is killed before {@link webdriver.WebDriver#quit()} is
|
||||
* called.
|
||||
* @param {boolean} detach Whether to leave the browser running if the
|
||||
* chromedriver service is killed before the session.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
detachDriver(detach: boolean): Options;
|
||||
/**
|
||||
* Sets the path to the Chrome binary to use. On Mac OS X, this path should
|
||||
* reference the actual Chrome executable, not just the application binary
|
||||
* (e.g. '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome').
|
||||
*
|
||||
* The binary path be absolute or relative to the chromedriver server
|
||||
* executable, but it must exist on the machine that will launch Chrome.
|
||||
*
|
||||
* @param {string} path The path to the Chrome binary to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeBinaryPath(path: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the user preferences for Chrome's user profile. See the 'Preferences'
|
||||
* file in Chrome's user data directory for examples.
|
||||
* @param {!Object} prefs Dictionary of user preferences to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setUserPreferences(prefs: any): Options;
|
||||
/**
|
||||
* Sets whether to leave the started Chrome browser running if the controlling
|
||||
* ChromeDriver service is killed before {@link webdriver.WebDriver#quit()} is
|
||||
* called.
|
||||
* @param {boolean} detach Whether to leave the browser running if the
|
||||
* chromedriver service is killed before the session.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
detachDriver(detach: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the logging preferences for the new session.
|
||||
* @param {!webdriver.logging.Preferences} prefs The logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
|
||||
/**
|
||||
* Sets the user preferences for Chrome's user profile. See the 'Preferences'
|
||||
* file in Chrome's user data directory for examples.
|
||||
* @param {!Object} prefs Dictionary of user preferences to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setUserPreferences(prefs: any): Options;
|
||||
|
||||
/**
|
||||
* Sets the performance logging preferences. Options include:
|
||||
*
|
||||
* - `enableNetwork`: Whether or not to collect events from Network domain.
|
||||
* - `enablePage`: Whether or not to collect events from Page domain.
|
||||
* - `enableTimeline`: Whether or not to collect events from Timeline domain.
|
||||
* Note: when tracing is enabled, Timeline domain is implicitly disabled,
|
||||
* unless `enableTimeline` is explicitly set to true.
|
||||
* - `tracingCategories`: A comma-separated string of Chrome tracing categories
|
||||
* for which trace events should be collected. An unspecified or empty
|
||||
* string disables tracing.
|
||||
* - `bufferUsageReportingInterval`: The requested number of milliseconds
|
||||
* between DevTools trace buffer usage events. For example, if 1000, then
|
||||
* once per second, DevTools will report how full the trace buffer is. If a
|
||||
* report indicates the buffer usage is 100%, a warning will be issued.
|
||||
*
|
||||
* @param {{enableNetwork: boolean,
|
||||
* enablePage: boolean,
|
||||
* enableTimeline: boolean,
|
||||
* tracingCategories: string,
|
||||
* bufferUsageReportingInterval: number}} prefs The performance
|
||||
* logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setPerfLoggingPrefs(prefs: IPerfLoggingPrefs): Options;
|
||||
/**
|
||||
* Sets the performance logging preferences. Options include:
|
||||
*
|
||||
* - `enableNetwork`: Whether or not to collect events from Network domain.
|
||||
* - `enablePage`: Whether or not to collect events from Page domain.
|
||||
* - `enableTimeline`: Whether or not to collect events from Timeline domain.
|
||||
* Note: when tracing is enabled, Timeline domain is implicitly disabled,
|
||||
* unless `enableTimeline` is explicitly set to true.
|
||||
* - `tracingCategories`: A comma-separated string of Chrome tracing
|
||||
* categories for which trace events should be collected. An unspecified or
|
||||
* empty string disables tracing.
|
||||
* - `bufferUsageReportingInterval`: The requested number of milliseconds
|
||||
* between DevTools trace buffer usage events. For example, if 1000, then
|
||||
* once per second, DevTools will report how full the trace buffer is. If
|
||||
* a report indicates the buffer usage is 100%, a warning will be issued.
|
||||
*
|
||||
* @param {{enableNetwork: boolean,
|
||||
* enablePage: boolean,
|
||||
* enableTimeline: boolean,
|
||||
* tracingCategories: string,
|
||||
* bufferUsageReportingInterval: number}} prefs The performance
|
||||
* logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setPerfLoggingPrefs(prefs: IPerfLoggingPrefs): Options;
|
||||
|
||||
/**
|
||||
* Sets preferences for the 'Local State' file in Chrome's user data
|
||||
* directory.
|
||||
* @param {!Object} state Dictionary of local state preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLocalState(state: any): Options;
|
||||
/**
|
||||
* Sets preferences for the 'Local State' file in Chrome's user data
|
||||
* directory.
|
||||
* @param {!Object} state Dictionary of local state preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLocalState(state: any): Options;
|
||||
|
||||
/**
|
||||
* Sets the name of the activity hosting a Chrome-based Android WebView. This
|
||||
* option must be set to connect to an [Android WebView](
|
||||
* https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android)
|
||||
*
|
||||
* @param {string} name The activity name.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidActivity(name: string): Options;
|
||||
/**
|
||||
* Sets the name of the activity hosting a Chrome-based Android WebView. This
|
||||
* option must be set to connect to an [Android WebView](
|
||||
* https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android)
|
||||
*
|
||||
* @param {string} name The activity name.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidActivity(name: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the device serial number to connect to via ADB. If not specified, the
|
||||
* ChromeDriver will select an unused device at random. An error will be
|
||||
* returned if all devices already have active sessions.
|
||||
*
|
||||
* @param {string} serial The device serial number to connect to.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidDeviceSerial(serial: string): Options;
|
||||
/**
|
||||
* Sets the device serial number to connect to via ADB. If not specified, the
|
||||
* ChromeDriver will select an unused device at random. An error will be
|
||||
* returned if all devices already have active sessions.
|
||||
*
|
||||
* @param {string} serial The device serial number to connect to.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidDeviceSerial(serial: string): Options;
|
||||
|
||||
/**
|
||||
* Configures the ChromeDriver to launch Chrome on Android via adb. This
|
||||
* function is shorthand for
|
||||
* {@link #androidPackage options.androidPackage('com.android.chrome')}.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidChrome(): Options;
|
||||
/**
|
||||
* Configures the ChromeDriver to launch Chrome on Android via adb. This
|
||||
* function is shorthand for
|
||||
* {@link #androidPackage options.androidPackage('com.android.chrome')}.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidChrome(): Options;
|
||||
|
||||
/**
|
||||
* Sets the package name of the Chrome or WebView app.
|
||||
*
|
||||
* @param {?string} pkg The package to connect to, or `null` to disable Android
|
||||
* and switch back to using desktop Chrome.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidPackage(pkg: string): Options;
|
||||
/**
|
||||
* Sets the package name of the Chrome or WebView app.
|
||||
*
|
||||
* @param {?string} pkg The package to connect to, or `null` to disable
|
||||
* Android and switch back to using desktop Chrome.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidPackage(pkg: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the process name of the Activity hosting the WebView (as given by `ps`).
|
||||
* If not specified, the process name is assumed to be the same as
|
||||
* {@link #androidPackage}.
|
||||
*
|
||||
* @param {string} processName The main activity name.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidProcess(processName: string): Options;
|
||||
/**
|
||||
* Sets the process name of the Activity hosting the WebView (as given by
|
||||
* `ps`). If not specified, the process name is assumed to be the same as
|
||||
* {@link #androidPackage}.
|
||||
*
|
||||
* @param {string} processName The main activity name.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidProcess(processName: string): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to connect to an already-running instead of the specified
|
||||
* {@linkplain #androidProcess app} instead of launching the app with a clean
|
||||
* data directory.
|
||||
*
|
||||
* @param {boolean} useRunning Whether to connect to a running instance.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidUseRunningApp(useRunning: boolean): Options;
|
||||
/**
|
||||
* Sets whether to connect to an already-running instead of the specified
|
||||
* {@linkplain #androidProcess app} instead of launching the app with a clean
|
||||
* data directory.
|
||||
*
|
||||
* @param {boolean} useRunning Whether to connect to a running instance.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidUseRunningApp(useRunning: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the path to Chrome's log file. This path should exist on the machine
|
||||
* that will launch Chrome.
|
||||
* @param {string} path Path to the log file to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeLogFile(path: string): Options;
|
||||
/**
|
||||
* Sets the path to Chrome's log file. This path should exist on the machine
|
||||
* that will launch Chrome.
|
||||
* @param {string} path Path to the log file to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeLogFile(path: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the directory to store Chrome minidumps in. This option is only
|
||||
* supported when ChromeDriver is running on Linux.
|
||||
* @param {string} path The directory path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeMinidumpPath(path: string): Options;
|
||||
/**
|
||||
* Sets the directory to store Chrome minidumps in. This option is only
|
||||
* supported when ChromeDriver is running on Linux.
|
||||
* @param {string} path The directory path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeMinidumpPath(path: string): Options;
|
||||
|
||||
/**
|
||||
* Configures Chrome to emulate a mobile device. For more information, refer
|
||||
* to the ChromeDriver project page on [mobile emulation][em]. Configuration
|
||||
* options include:
|
||||
*
|
||||
* - `deviceName`: The name of a pre-configured [emulated device][devem]
|
||||
* - `width`: screen width, in pixels
|
||||
* - `height`: screen height, in pixels
|
||||
* - `pixelRatio`: screen pixel ratio
|
||||
*
|
||||
* __Example 1: Using a Pre-configured Device__
|
||||
*
|
||||
* let options = new chrome.Options().setMobileEmulation(
|
||||
* {deviceName: 'Google Nexus 5'});
|
||||
*
|
||||
* let driver = new chrome.Driver(options);
|
||||
*
|
||||
* __Example 2: Using Custom Screen Configuration__
|
||||
*
|
||||
* let options = new chrome.Options().setMobileEmulation({
|
||||
* width: 360,
|
||||
* height: 640,
|
||||
* pixelRatio: 3.0
|
||||
* });
|
||||
*
|
||||
* let driver = new chrome.Driver(options);
|
||||
*
|
||||
*
|
||||
* [em]: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation
|
||||
* [devem]: https://developer.chrome.com/devtools/docs/device-mode
|
||||
*
|
||||
* @param {?({deviceName: string}|
|
||||
* {width: number, height: number, pixelRatio: number})} config The
|
||||
* mobile emulation configuration, or `null` to disable emulation.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setMobileEmulation(config: any): Options;
|
||||
|
||||
/**
|
||||
* Sets the proxy settings for the new session.
|
||||
* @param {webdriver.ProxyConfig} proxy The proxy configuration to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProxy(proxy: webdriver.ProxyConfig): Options;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link webdriver.Capabilities} object.
|
||||
* @param {webdriver.Capabilities=} opt_capabilities The capabilities to merge
|
||||
* these options into, if any.
|
||||
* @return {!webdriver.Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
|
||||
/**
|
||||
* Configures Chrome to emulate a mobile device. For more information, refer
|
||||
* to the ChromeDriver project page on [mobile emulation][em]. Configuration
|
||||
* options include:
|
||||
*
|
||||
* - `deviceName`: The name of a pre-configured [emulated device][devem]
|
||||
* - `width`: screen width, in pixels
|
||||
* - `height`: screen height, in pixels
|
||||
* - `pixelRatio`: screen pixel ratio
|
||||
*
|
||||
* __Example 1: Using a Pre-configured Device__
|
||||
*
|
||||
* let options = new chrome.Options().setMobileEmulation(
|
||||
* {deviceName: 'Google Nexus 5'});
|
||||
*
|
||||
* let driver = new chrome.Driver(options);
|
||||
*
|
||||
* __Example 2: Using Custom Screen Configuration__
|
||||
*
|
||||
* let options = new chrome.Options().setMobileEmulation({
|
||||
* width: 360,
|
||||
* height: 640,
|
||||
* pixelRatio: 3.0
|
||||
* });
|
||||
*
|
||||
* let driver = new chrome.Driver(options);
|
||||
*
|
||||
*
|
||||
* [em]: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation
|
||||
* [devem]: https://developer.chrome.com/devtools/docs/device-mode
|
||||
*
|
||||
* @param {?({deviceName: string}|
|
||||
* {width: number, height: number, pixelRatio: number})} config The
|
||||
* mobile emulation configuration, or `null` to disable emulation.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setMobileEmulation(config: any): Options;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,47 +291,47 @@ export class Options {
|
||||
* server.
|
||||
*/
|
||||
export class ServiceBuilder extends remote.DriverService.Builder {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the chromedriver on the current
|
||||
* PATH.
|
||||
* @throws {Error} If provided executable does not exist, or the chromedriver
|
||||
* cannot be found on the PATH.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the chromedriver on the current
|
||||
* PATH.
|
||||
* @throws {Error} If provided executable does not exist, or the chromedriver
|
||||
* cannot be found on the PATH.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
|
||||
/**
|
||||
* Sets which port adb is listening to. _The ChromeDriver will connect to adb
|
||||
* if an {@linkplain Options#androidPackage Android session} is requested, but
|
||||
* adb **must** be started beforehand._
|
||||
*
|
||||
* @param {number} port Which port adb is running on.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
setAdbPort(port: number): this;
|
||||
/**
|
||||
* Sets which port adb is listening to. _The ChromeDriver will connect to adb
|
||||
* if an {@linkplain Options#androidPackage Android session} is requested, but
|
||||
* adb **must** be started beforehand._
|
||||
*
|
||||
* @param {number} port Which port adb is running on.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
setAdbPort(port: number): this;
|
||||
|
||||
/**
|
||||
* Sets the path of the log file the driver should log to. If a log file is
|
||||
* not specified, the driver will log to stderr.
|
||||
* @param {string} path Path of the log file to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
loggingTo(path: string): this;
|
||||
/**
|
||||
* Sets the path of the log file the driver should log to. If a log file is
|
||||
* not specified, the driver will log to stderr.
|
||||
* @param {string} path Path of the log file to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
loggingTo(path: string): this;
|
||||
|
||||
/**
|
||||
* Enables verbose logging.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
enableVerboseLogging(): this;
|
||||
/**
|
||||
* Enables verbose logging.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
enableVerboseLogging(): this;
|
||||
|
||||
/**
|
||||
* Sets the number of threads the driver should use to manage HTTP requests.
|
||||
* By default, the driver will use 4 threads.
|
||||
* @param {number} n The number of threads to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
setNumHttpThreads(n: number): this;
|
||||
/**
|
||||
* Sets the number of threads the driver should use to manage HTTP requests.
|
||||
* By default, the driver will use 4 threads.
|
||||
* @param {number} n The number of threads to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
setNumHttpThreads(n: number): this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+40
-58
@@ -2,63 +2,45 @@ import * as webdriver from './index';
|
||||
import * as remote from './remote';
|
||||
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new browser session for Microsoft's Edge browser.
|
||||
*
|
||||
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
|
||||
* options.
|
||||
* @param {remote.DriverService=} opt_service The session to use; will use
|
||||
* the {@linkplain #getDefaultService default service} by default.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to use, or
|
||||
* {@code null} to use the currently active flow.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: webdriver.CreateSessionCapabilities, opt_service?: remote.DriverService, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
/**
|
||||
* Creates a new browser session for Microsoft's Edge browser.
|
||||
*
|
||||
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
|
||||
* options.
|
||||
* @param {remote.DriverService=} opt_service The session to use; will use
|
||||
* the {@linkplain #getDefaultService default service} by default.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(
|
||||
opt_config?: webdriver.CreateSessionCapabilities, opt_service?: remote.DriverService): Driver;
|
||||
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for managing MicrosoftEdgeDriver specific options.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* Extracts the MicrosoftEdgeDriver specific options from the given
|
||||
* capabilities object.
|
||||
* @param {!capabilities.Capabilities} caps The capabilities object.
|
||||
* @return {!Options} The MicrosoftEdgeDriver options.
|
||||
*/
|
||||
static fromCapabilities(cap: webdriver.Capabilities): 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 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;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link capabilities.Capabilities}
|
||||
* object.
|
||||
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
|
||||
* merge these options into, if any.
|
||||
* @return {!capabilities.Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,14 +48,14 @@ export class Options {
|
||||
* MicrosoftEdgeDriver server in a child process.
|
||||
*/
|
||||
export class ServiceBuilder extends remote.DriverService.Builder {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the MicrosoftEdgeDriver on the current
|
||||
* PATH.
|
||||
* @throws {Error} If provided executable does not exist, or the
|
||||
* MicrosoftEdgeDriver cannot be found on the PATH.
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the MicrosoftEdgeDriver on the current
|
||||
* PATH.
|
||||
* @throws {Error} If provided executable does not exist, or the
|
||||
* MicrosoftEdgeDriver cannot be found on the PATH.
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+90
-291
@@ -1,246 +1,46 @@
|
||||
import * as http from './http';
|
||||
import * as webdriver from './index';
|
||||
import * as remote from './remote';
|
||||
import * as http from './http';
|
||||
|
||||
/**
|
||||
* Manages a Firefox subprocess configured for use with WebDriver.
|
||||
*/
|
||||
export class Binary {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the Firefox binary to use. If not
|
||||
* specified, will attempt to locate Firefox on the current system.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
|
||||
/**
|
||||
* Add arguments to the command line used to start Firefox.
|
||||
* @param {...(string|!Array.<string>)} var_args Either the arguments to add as
|
||||
* varargs, or the arguments as an array.
|
||||
*/
|
||||
addArguments(...var_args: string[]): void;
|
||||
|
||||
/**
|
||||
* Launches Firefox and eturns a promise that will be fulfilled when the process
|
||||
* terminates.
|
||||
* @param {string} profile Path to the profile directory to use.
|
||||
* @return {!promise.Promise.<!exec.Result>} A promise for the process result.
|
||||
* @throws {Error} If this instance has already been started.
|
||||
*/
|
||||
launch(profile: string): webdriver.promise.Promise<any>;
|
||||
|
||||
/**
|
||||
* Kills the managed Firefox process.
|
||||
* @return {!promise.Promise} A promise for when the process has terminated.
|
||||
*/
|
||||
kill(): webdriver.promise.Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Models a Firefox proifle directory for use with the FirefoxDriver. The
|
||||
* {@code Proifle} directory uses an in-memory model until {@link #writeToDisk}
|
||||
* is called.
|
||||
*/
|
||||
export class Profile {
|
||||
/**
|
||||
* @param {string=} opt_dir Path to an existing Firefox profile directory to
|
||||
* use a template for this profile. If not specified, a blank profile will
|
||||
* be used.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_dir?: string);
|
||||
|
||||
/**
|
||||
* Registers an extension to be included with this profile.
|
||||
* @param {string} extension Path to the extension to include, as either an
|
||||
* unpacked extension directory or the path to a xpi file.
|
||||
*/
|
||||
addExtension(extension: string): void;
|
||||
|
||||
/**
|
||||
* Sets a desired preference for this profile.
|
||||
* @param {string} key The preference key.
|
||||
* @param {(string|number|boolean)} value The preference value.
|
||||
* @throws {Error} If attempting to set a frozen preference.
|
||||
*/
|
||||
setPreference(key: string, value: string): void;
|
||||
setPreference(key: string, value: number): void;
|
||||
setPreference(key: string, value: boolean): void;
|
||||
|
||||
/**
|
||||
* Returns the currently configured value of a profile preference. This does
|
||||
* not include any defaults defined in the profile's template directory user.js
|
||||
* file (if a template were specified on construction).
|
||||
* @param {string} key The desired preference.
|
||||
* @return {(string|number|boolean|undefined)} The current value of the
|
||||
* requested preference.
|
||||
*/
|
||||
getPreference(key: string): any;
|
||||
|
||||
/**
|
||||
* @return {number} The port this profile is currently configured to use, or
|
||||
* 0 if the port will be selected at random when the profile is written
|
||||
* to disk.
|
||||
*/
|
||||
getPort(): number;
|
||||
|
||||
/**
|
||||
* Sets the port to use for the WebDriver extension loaded by this profile.
|
||||
* @param {number} port The desired port, or 0 to use any free port.
|
||||
*/
|
||||
setPort(port: number): void;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the FirefoxDriver is configured to automatically
|
||||
* accept untrusted SSL certificates.
|
||||
*/
|
||||
acceptUntrustedCerts(): boolean;
|
||||
|
||||
/**
|
||||
* Sets whether the FirefoxDriver should automatically accept untrusted SSL
|
||||
* certificates.
|
||||
* @param {boolean} value .
|
||||
*/
|
||||
setAcceptUntrustedCerts(value: boolean): void;
|
||||
|
||||
/**
|
||||
* Sets whether to assume untrusted certificates come from untrusted issuers.
|
||||
* @param {boolean} value .
|
||||
*/
|
||||
setAssumeUntrustedCertIssuer(value: boolean): void;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether to assume untrusted certs come from untrusted
|
||||
* issuers.
|
||||
*/
|
||||
assumeUntrustedCertIssuer(): boolean;
|
||||
|
||||
/**
|
||||
* Sets whether to use native events with this profile.
|
||||
* @param {boolean} enabled .
|
||||
*/
|
||||
setNativeEventsEnabled(enabled: boolean): void;
|
||||
|
||||
/**
|
||||
* Returns whether native events are enabled in this profile.
|
||||
* @return {boolean} .
|
||||
*/
|
||||
nativeEventsEnabled(): boolean;
|
||||
|
||||
/**
|
||||
* Writes this profile to disk.
|
||||
* @param {boolean=} opt_excludeWebDriverExt Whether to exclude the WebDriver
|
||||
* extension from the generated profile. Used to reduce the size of an
|
||||
* {@link #encode() encoded profile} since the server will always install
|
||||
* the extension itself.
|
||||
* @return {!promise.Promise.<string>} A promise for the path to the new
|
||||
* profile directory.
|
||||
*/
|
||||
writeToDisk(opt_excludeWebDriverExt?: boolean): webdriver.promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* Encodes this profile as a zipped, base64 encoded directory.
|
||||
* @return {!promise.Promise.<string>} A promise for the encoded profile.
|
||||
*/
|
||||
encode(): webdriver.promise.Promise<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration options for the FirefoxDriver.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* Specify additional command line arguments that should be used when starting
|
||||
* the Firefox browser.
|
||||
*
|
||||
* @param {...(string|!Array<string>)} args The arguments to include.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...args: string[]): Options;
|
||||
export class Options extends webdriver.Capabilities {
|
||||
/**
|
||||
* Sets the profile to use. The profile may be specified as a
|
||||
* {@link Profile} object or as the path to an existing Firefox profile to use
|
||||
* as a template.
|
||||
*
|
||||
* @param {(string|!Profile)} profile The profile to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProfile(profile: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the browser to be in headless mode.
|
||||
*
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
headless(): Options;
|
||||
/**
|
||||
* Sets the binary to use. The binary may be specified as the path to a
|
||||
* Firefox executable, or as a {@link Binary} object.
|
||||
*
|
||||
* @param {(string|!Binary)} binary The binary to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setBinary(binary: string|any): Options;
|
||||
|
||||
/**
|
||||
* Sets the initial window size when running in
|
||||
* {@linkplain #headless headless} mode.
|
||||
*
|
||||
* @param {{width: number, height: number}} size The desired window size.
|
||||
* @return {!Options} A self reference.
|
||||
* @throws {TypeError} if width or height is unspecified, not a number, or
|
||||
* less than or equal to 0.
|
||||
*/
|
||||
windowSize(size: { width: number, height: number }): Options;
|
||||
/**
|
||||
* Sets the proxy to use.
|
||||
*
|
||||
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProxy(proxy: webdriver.ProxyConfig): Options;
|
||||
|
||||
/**
|
||||
* Add extensions that should be installed when starting Firefox.
|
||||
*
|
||||
* @param {...string} paths The paths to the extension XPI files to install.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addExtensions(...paths: string[]): Options;
|
||||
|
||||
/**
|
||||
* @param {string} key the preference key.
|
||||
* @param {(string|number|boolean)} value the preference value.
|
||||
* @return {!Options} A self reference.
|
||||
* @throws {TypeError} if either the key or value has an invalid type.
|
||||
*/
|
||||
setPreference(key: string, value: string | number | boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the profile to use. The profile may be specified as a
|
||||
* {@link Profile} object or as the path to an existing Firefox profile to use
|
||||
* as a template.
|
||||
*
|
||||
* @param {(string|!Profile)} profile The profile to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProfile(profile: string | any): Options;
|
||||
|
||||
/**
|
||||
* Sets the binary to use. The binary may be specified as the path to a Firefox
|
||||
* executable, or as a {@link Binary} object.
|
||||
*
|
||||
* @param {(string|!Binary)} binary The binary to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setBinary(binary: string | any): Options;
|
||||
|
||||
/**
|
||||
* Sets the logging preferences for the new session.
|
||||
* @param {logging.Preferences} prefs The logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLoggingPreferences(prefs: webdriver.logging.Preferences): Options;
|
||||
|
||||
/**
|
||||
* Sets the proxy to use.
|
||||
*
|
||||
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProxy(proxy: webdriver.ProxyConfig): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to use Mozilla's geckodriver to drive the browser. This option
|
||||
* is enabled by default and required for Firefox 47+.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable the geckodriver.
|
||||
* @see https://github.com/mozilla/geckodriver
|
||||
*/
|
||||
useGeckoDriver(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Converts these options to a {@link capabilities.Capabilities} instance.
|
||||
*
|
||||
* @return {!capabilities.Capabilities} A new capabilities object.
|
||||
*/
|
||||
toCapabilities(): webdriver.Capabilities;
|
||||
/**
|
||||
* Sets whether to use Mozilla's geckodriver to drive the browser. This option
|
||||
* is enabled by default and required for Firefox 47+.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable the geckodriver.
|
||||
* @see https://github.com/mozilla/geckodriver
|
||||
*/
|
||||
useGeckoDriver(enable: boolean): Options;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,52 +53,51 @@ export function findWires(): string;
|
||||
* @param {(string|!Binary)} binary .
|
||||
* @return {!remote.DriverService} .
|
||||
*/
|
||||
export function createWiresService(binary: string | any): remote.DriverService;
|
||||
export function createWiresService(binary: string|any): remote.DriverService;
|
||||
|
||||
/**
|
||||
* @param {(Profile|string)} profile The profile to prepare.
|
||||
* @param {number} port The port the FirefoxDriver should listen on.
|
||||
* @return {!Promise<string>} a promise for the path to the profile directory.
|
||||
*/
|
||||
export function prepareProfile(profile: string | any, port: number): any;
|
||||
export function prepareProfile(profile: string|any, port: number): any;
|
||||
|
||||
/**
|
||||
* A WebDriver client for Firefox.
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new Firefox session.
|
||||
*
|
||||
* @param {(Options|capabilities.Capabilities|Object)=} opt_config The
|
||||
* configuration options for this driver, specified as either an
|
||||
* {@link Options} or {@link capabilities.Capabilities}, or as a raw hash
|
||||
* object.
|
||||
* @param {(http.Executor|remote.DriverService)=} opt_executor Either a
|
||||
* pre-configured command executor to use for communicating with an
|
||||
* externally managed remote end (which is assumed to already be running),
|
||||
* or the `DriverService` to use to start the geckodriver in a child
|
||||
* process.
|
||||
*
|
||||
* If an executor is provided, care should e taken not to use reuse it with
|
||||
* other clients as its internal command mappings will be updated to support
|
||||
* Firefox-specific commands.
|
||||
*
|
||||
* _This parameter may only be used with Mozilla's GeckoDriver._
|
||||
*
|
||||
* @param {promise.ControlFlow=} opt_flow The flow to
|
||||
* schedule commands through. Defaults to the active flow object.
|
||||
* @throws {Error} If a custom command executor is provided and the driver is
|
||||
* configured to use the legacy FirefoxDriver from the Selenium project.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: Options | webdriver.Capabilities, opt_executor?: http.Executor | remote.DriverService, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
/**
|
||||
* Creates a new Firefox session.
|
||||
*
|
||||
* @param {(Options|capabilities.Capabilities|Object)=} opt_config The
|
||||
* configuration options for this driver, specified as either an
|
||||
* {@link Options} or {@link capabilities.Capabilities}, or as a raw hash
|
||||
* object.
|
||||
* @param {(http.Executor|remote.DriverService)=} opt_executor Either a
|
||||
* pre-configured command executor to use for communicating with an
|
||||
* externally managed remote end (which is assumed to already be running),
|
||||
* or the `DriverService` to use to start the geckodriver in a child
|
||||
* process.
|
||||
*
|
||||
* If an executor is provided, care should e taken not to use reuse it with
|
||||
* other clients as its internal command mappings will be updated to support
|
||||
* Firefox-specific commands.
|
||||
*
|
||||
* _This parameter may only be used with Mozilla's GeckoDriver._
|
||||
* @throws {Error} If a custom command executor is provided and the driver is
|
||||
* configured to use the legacy FirefoxDriver from the Selenium project.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(
|
||||
opt_config?: Options|webdriver.Capabilities,
|
||||
opt_executor?: http.Executor|remote.DriverService): Driver;
|
||||
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,29 +106,29 @@ export class Driver extends webdriver.WebDriver {
|
||||
* process.
|
||||
*/
|
||||
export class ServiceBuilder extends remote.DriverService.Builder {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the geckodriver on the system PATH.
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the geckodriver on the system PATH.
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
|
||||
/**
|
||||
* Enables verbose logging.
|
||||
*
|
||||
* @param {boolean=} opt_trace Whether to enable trace-level logging. By
|
||||
* default, only debug logging is enabled.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
enableVerboseLogging(opt_trace?: boolean): this;
|
||||
/**
|
||||
* Enables verbose logging.
|
||||
*
|
||||
* @param {boolean=} opt_trace Whether to enable trace-level logging. By
|
||||
* default, only debug logging is enabled.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
enableVerboseLogging(opt_trace?: boolean): this;
|
||||
|
||||
/**
|
||||
* Sets the path to the executable Firefox binary that the geckodriver should
|
||||
* use. If this method is not called, this builder will attempt to locate
|
||||
* Firefox in the default installation location for the current platform.
|
||||
*
|
||||
* @param {(string|!Binary)} binary Path to the executable Firefox binary to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
* @see Binary#locate()
|
||||
*/
|
||||
setFirefoxBinary(binary: string | Binary): this;
|
||||
/**
|
||||
* Sets the path to the executable Firefox binary that the geckodriver should
|
||||
* use. If this method is not called, this builder will attempt to locate
|
||||
* Firefox in the default installation location for the current platform.
|
||||
*
|
||||
* @param {(string|!Binary)} binary Path to the executable Firefox binary to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
* @see Binary#locate()
|
||||
*/
|
||||
setFirefoxBinary(binary: string): this;
|
||||
}
|
||||
|
||||
Vendored
+59
-67
@@ -14,20 +14,15 @@ export function headersToString(headers: any): string;
|
||||
* @final
|
||||
*/
|
||||
export class Request {
|
||||
/**
|
||||
* @param {string} method The HTTP method to use for the request.
|
||||
* @param {string} path The path on the server to send the request to.
|
||||
* @param {Object=} opt_data This request's non-serialized JSON payload data.
|
||||
*/
|
||||
constructor(method: string, path: string, opt_data?: Object);
|
||||
/**
|
||||
* @param {string} method The HTTP method to use for the request.
|
||||
* @param {string} path The path on the server to send the request to.
|
||||
* @param {Object=} opt_data This request's non-serialized JSON payload data.
|
||||
*/
|
||||
constructor(method: string, path: string, opt_data?: Object);
|
||||
|
||||
headers: Map<string, string>;
|
||||
method: string;
|
||||
path: string;
|
||||
data: Object;
|
||||
|
||||
/** @override */
|
||||
toString(): string;
|
||||
/** @override */
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,20 +30,16 @@ export class Request {
|
||||
* @final
|
||||
*/
|
||||
export class Response {
|
||||
/**
|
||||
* @param {number} status The response code.
|
||||
* @param {!Object<string>} headers The response headers. All header names
|
||||
* will be converted to lowercase strings for consistent lookups.
|
||||
* @param {string} body The response body.
|
||||
*/
|
||||
constructor(status: number, headers: Object, body: string);
|
||||
/**
|
||||
* @param {number} status The response code.
|
||||
* @param {!Object<string>} headers The response headers. All header names
|
||||
* will be converted to lowercase strings for consistent lookups.
|
||||
* @param {string} body The response body.
|
||||
*/
|
||||
constructor(status: number, headers: Object, body: string);
|
||||
|
||||
status: number;
|
||||
body: string;
|
||||
headers: Map<string, string>;
|
||||
|
||||
/** @override */
|
||||
toString(): string;
|
||||
/** @override */
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export function post(path: string): any;
|
||||
@@ -60,25 +51,25 @@ export function resource(method: string, path: string): any;
|
||||
* A basic HTTP client used to send messages to a remote end.
|
||||
*/
|
||||
export class HttpClient {
|
||||
/**
|
||||
* @param {string} serverUrl URL for the WebDriver server to send commands to.
|
||||
* @param {http.Agent=} opt_agent The agent to use for each request.
|
||||
* Defaults to `http.globalAgent`.
|
||||
* @param {?string=} opt_proxy The proxy to use for the connection to the
|
||||
* server. Default is to use no proxy.
|
||||
*/
|
||||
constructor(serverUrl: string, opt_agent?: any, opt_proxy?: string);
|
||||
/**
|
||||
* @param {string} serverUrl URL for the WebDriver server to send commands to.
|
||||
* @param {http.Agent=} opt_agent The agent to use for each request.
|
||||
* Defaults to `http.globalAgent`.
|
||||
* @param {?string=} opt_proxy The proxy to use for the connection to the
|
||||
* server. Default is to use no proxy.
|
||||
*/
|
||||
constructor(serverUrl: string, opt_agent?: any, opt_proxy?: string);
|
||||
|
||||
/**
|
||||
* Sends a request to the server. The client will automatically follow any
|
||||
* redirects returned by the server, fulfilling the returned promise with the
|
||||
* final response.
|
||||
*
|
||||
* @param {!HttpRequest} httpRequest The request to send.
|
||||
* @return {!promise.Promise<HttpResponse>} A promise that will be fulfilled
|
||||
* with the server's response.
|
||||
*/
|
||||
send(httpRequest: Request): webdriver.promise.Promise<Response>;
|
||||
/**
|
||||
* Sends a request to the server. The client will automatically follow any
|
||||
* redirects returned by the server, fulfilling the returned promise with
|
||||
* the final response.
|
||||
*
|
||||
* @param {!HttpRequest} httpRequest The request to send.
|
||||
* @return {!Promise<HttpResponse>} A promise that will be fulfilled
|
||||
* with the server's response.
|
||||
*/
|
||||
send(httpRequest: Request): Promise<Response>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +81,8 @@ export class HttpClient {
|
||||
* @param {?string=} opt_data The data to send with the request.
|
||||
* @param {?string=} opt_proxy The proxy server to use for the request.
|
||||
*/
|
||||
export function sendRequest(options: Object, onOk: any, onError: any, opt_data?: string, opt_proxy?: string): any;
|
||||
export function sendRequest(
|
||||
options: Object, onOk: any, onError: any, opt_data?: string, opt_proxy?: string): any;
|
||||
|
||||
/**
|
||||
* A command executor that communicates with the server using HTTP + JSON.
|
||||
@@ -106,30 +98,30 @@ export function sendRequest(options: Object, onOk: any, onError: any, opt_data?:
|
||||
* @implements {cmd.Executor}
|
||||
*/
|
||||
export class Executor {
|
||||
/**
|
||||
* @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 | webdriver.promise.IThenable<HttpClient>);
|
||||
/**
|
||||
* @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|Promise<HttpClient>);
|
||||
|
||||
/**
|
||||
* Defines a new command for use with this executor. When a command is sent,
|
||||
* the {@code path} will be preprocessed using the command's parameters; any
|
||||
* path segments prefixed with ':' will be replaced by the parameter of the
|
||||
* same name. For example, given '/person/:name' and the parameters
|
||||
* '{name: 'Bob'}', the final command path will be '/person/Bob'.
|
||||
*
|
||||
* @param {string} name The command name.
|
||||
* @param {string} method The HTTP method to use when sending this command.
|
||||
* @param {string} path The path to send the command to, relative to
|
||||
* the WebDriver server's command root and of the form
|
||||
* '/path/:variable/segment'.
|
||||
*/
|
||||
defineCommand(name: string, method: string, path: string): void;
|
||||
/**
|
||||
* Defines a new command for use with this executor. When a command is sent,
|
||||
* the {@code path} will be preprocessed using the command's parameters; any
|
||||
* path segments prefixed with ':' will be replaced by the parameter of the
|
||||
* same name. For example, given '/person/:name' and the parameters
|
||||
* '{name: 'Bob'}', the final command path will be '/person/Bob'.
|
||||
*
|
||||
* @param {string} name The command name.
|
||||
* @param {string} method The HTTP method to use when sending this command.
|
||||
* @param {string} path The path to send the command to, relative to
|
||||
* the WebDriver server's command root and of the form
|
||||
* '/path/:variable/segment'.
|
||||
*/
|
||||
defineCommand(name: string, method: string, path: string): void;
|
||||
|
||||
/** @override */
|
||||
execute(command: any): any;
|
||||
/** @override */
|
||||
execute(command: any): any;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+161
-178
@@ -4,205 +4,188 @@ import * as webdriver from './index';
|
||||
* A WebDriver client for Microsoft's Internet Explorer.
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new session for Microsoft's Internet Explorer.
|
||||
*
|
||||
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
|
||||
* options.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to use,
|
||||
* or {@code null} to use the currently active flow.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: webdriver.Capabilities | Options, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
/**
|
||||
* Creates a new session for Microsoft's Internet Explorer.
|
||||
*
|
||||
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
|
||||
* options.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: webdriver.Capabilities|Options): Driver;
|
||||
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for managing IEDriver specific options.
|
||||
*/
|
||||
export class Options {
|
||||
constructor();
|
||||
export class Options extends webdriver.Capabilities {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Extracts the IEDriver specific options from the given capabilities
|
||||
* object.
|
||||
* @param {!capabilities.Capabilities} caps The capabilities object.
|
||||
* @return {!Options} The IEDriver options.
|
||||
*/
|
||||
static fromCapabilities(caps: webdriver.Capabilities): Options;
|
||||
/**
|
||||
* Whether to disable the protected mode settings check when the session is
|
||||
* created. Disbling this setting may lead to significant instability as the
|
||||
* browser may become unresponsive/hang. Only 'best effort' support is
|
||||
* provided when using this capability.
|
||||
*
|
||||
* For more information, refer to the IEDriver's
|
||||
* [required system configuration](http://goo.gl/eH0Yi3).
|
||||
*
|
||||
* @param {boolean} ignoreSettings Whether to ignore protected mode settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
introduceFlakinessByIgnoringProtectedModeSettings(ignoreSettings: boolean): Options;
|
||||
|
||||
/**
|
||||
* Whether to disable the protected mode settings check when the session is
|
||||
* created. Disbling this setting may lead to significant instability as the
|
||||
* browser may become unresponsive/hang. Only 'best effort' support is provided
|
||||
* when using this capability.
|
||||
*
|
||||
* For more information, refer to the IEDriver's
|
||||
* [required system configuration](http://goo.gl/eH0Yi3).
|
||||
*
|
||||
* @param {boolean} ignoreSettings Whether to ignore protected mode settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
introduceFlakinessByIgnoringProtectedModeSettings(ignoreSettings: boolean): Options;
|
||||
/**
|
||||
* Indicates whether to skip the check that the browser's zoom level is set to
|
||||
* 100%.
|
||||
*
|
||||
* @param {boolean} ignore Whether to ignore the browser's zoom level
|
||||
* settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
ignoreZoomSetting(ignore: boolean): Options;
|
||||
|
||||
/**
|
||||
* Indicates whether to skip the check that the browser's zoom level is set to
|
||||
* 100%.
|
||||
*
|
||||
* @param {boolean} ignore Whether to ignore the browser's zoom level settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
ignoreZoomSetting(ignore: boolean): Options;
|
||||
/**
|
||||
* Sets the initial URL loaded when IE starts. This is intended to be used
|
||||
* with
|
||||
* {@link #ignoreProtectedModeSettings} to allow the user to initialize IE in
|
||||
* the proper Protected Mode zone. Setting this option may cause browser
|
||||
* instability or flaky and unresponsive code. Only 'best effort' support is
|
||||
* provided when using this option.
|
||||
*
|
||||
* @param {string} url The initial browser URL.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
initialBrowserUrl(url: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the initial URL loaded when IE starts. This is intended to be used with
|
||||
* {@link #ignoreProtectedModeSettings} to allow the user to initialize IE in
|
||||
* the proper Protected Mode zone. Setting this option may cause browser
|
||||
* instability or flaky and unresponsive code. Only 'best effort' support is
|
||||
* provided when using this option.
|
||||
*
|
||||
* @param {string} url The initial browser URL.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
initialBrowserUrl(url: string): Options;
|
||||
/**
|
||||
* Configures whether to enable persistent mouse hovering (true by default).
|
||||
* Persistent hovering is achieved by continuously firing mouse over events at
|
||||
* the last location the mouse cursor has been moved to.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable persistent hovering.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
enablePersistentHover(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to enable persistent mouse hovering (true by default).
|
||||
* Persistent hovering is achieved by continuously firing mouse over events at
|
||||
* the last location the mouse cursor has been moved to.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable persistent hovering.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
enablePersistentHover(enable: boolean): Options;
|
||||
/**
|
||||
* Configures whether the driver should attempt to remove obsolete
|
||||
* {@linkplain webdriver.WebElement WebElements} from its internal cache on
|
||||
* page navigation (true by default). Disabling this option will cause the
|
||||
* driver to run with a larger memory footprint.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable element reference cleanup.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
enableElementCacheCleanup(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether the driver should attempt to remove obsolete
|
||||
* {@linkplain webdriver.WebElement WebElements} from its internal cache on
|
||||
* page navigation (true by default). Disabling this option will cause the
|
||||
* driver to run with a larger memory footprint.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable element reference cleanup.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
enableElementCacheCleanup(enable: boolean): Options;
|
||||
/**
|
||||
* Configures whether to require the IE window to have input focus before
|
||||
* performing any user interactions (i.e. mouse or keyboard events). This
|
||||
* option is disabled by default, but delivers much more accurate interaction
|
||||
* events when enabled.
|
||||
*
|
||||
* @param {boolean} require Whether to require window focus.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
requireWindowFocus(require: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to require the IE window to have input focus before
|
||||
* performing any user interactions (i.e. mouse or keyboard events). This
|
||||
* option is disabled by default, but delivers much more accurate interaction
|
||||
* events when enabled.
|
||||
*
|
||||
* @param {boolean} require Whether to require window focus.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
requireWindowFocus(require: boolean): Options;
|
||||
/**
|
||||
* Configures the timeout, in milliseconds, that the driver will attempt to
|
||||
* located and attach to a newly opened instance of Internet Explorer. The
|
||||
* default is zero, which indicates waiting indefinitely.
|
||||
*
|
||||
* @param {number} timeout How long to wait for IE.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
browserAttachTimeout(timeout: number): Options;
|
||||
|
||||
/**
|
||||
* Configures the timeout, in milliseconds, that the driver will attempt to
|
||||
* located and attach to a newly opened instance of Internet Explorer. The
|
||||
* default is zero, which indicates waiting indefinitely.
|
||||
*
|
||||
* @param {number} timeout How long to wait for IE.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
browserAttachTimeout(timeout: number): Options;
|
||||
/**
|
||||
* Configures whether to launch Internet Explorer using the CreateProcess API.
|
||||
* If this option is not specified, IE is launched using IELaunchURL, if
|
||||
* available. For IE 8 and above, this option requires the TabProcGrowth
|
||||
* registry value to be set to 0.
|
||||
*
|
||||
* @param {boolean} force Whether to use the CreateProcess API.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
forceCreateProcessApi(force: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to launch Internet Explorer using the CreateProcess API.
|
||||
* If this option is not specified, IE is launched using IELaunchURL, if
|
||||
* available. For IE 8 and above, this option requires the TabProcGrowth
|
||||
* registry value to be set to 0.
|
||||
*
|
||||
* @param {boolean} force Whether to use the CreateProcess API.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
forceCreateProcessApi(force: boolean): Options;
|
||||
/**
|
||||
* Specifies command-line switches to use when launching Internet Explorer.
|
||||
* This is only valid when used with {@link #forceCreateProcessApi}.
|
||||
*
|
||||
* @param {...(string|!Array.<string>)} var_args The arguments to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...var_args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Specifies command-line switches to use when launching Internet Explorer.
|
||||
* This is only valid when used with {@link #forceCreateProcessApi}.
|
||||
*
|
||||
* @param {...(string|!Array.<string>)} var_args The arguments to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...var_args: string[]): Options;
|
||||
/**
|
||||
* Configures whether proxies should be configured on a per-process basis. If
|
||||
* not set, setting a {@linkplain #setProxy proxy} will configure the system
|
||||
* proxy. The default behavior is to use the system proxy.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable per-process proxy settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
usePerProcessProxy(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether proxies should be configured on a per-process basis. If
|
||||
* not set, setting a {@linkplain #setProxy proxy} will configure the system
|
||||
* proxy. The default behavior is to use the system proxy.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable per-process proxy settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
usePerProcessProxy(enable: boolean): Options;
|
||||
/**
|
||||
* Configures whether to clear the cache, cookies, history, and saved form
|
||||
* data before starting the browser. _Using this capability will clear session
|
||||
* data for all running instances of Internet Explorer, including those
|
||||
* started manually._
|
||||
*
|
||||
* @param {boolean} cleanSession Whether to clear all session data on startup.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
ensureCleanSession(cleanSession: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to clear the cache, cookies, history, and saved form data
|
||||
* before starting the browser. _Using this capability will clear session data
|
||||
* for all running instances of Internet Explorer, including those started
|
||||
* manually._
|
||||
*
|
||||
* @param {boolean} cleanSession Whether to clear all session data on startup.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
ensureCleanSession(cleanSession: boolean): Options;
|
||||
/**
|
||||
* Sets the path to the log file the driver should log to.
|
||||
* @param {string} file The log file path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLogFile(file: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the path to the log file the driver should log to.
|
||||
* @param {string} file The log file path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLogFile(file: string): Options;
|
||||
/**
|
||||
* Sets the IEDriverServer's logging {@linkplain Level level}.
|
||||
* @param {Level} level The logging level.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLogLevel(level: webdriver.logging.Level): Options;
|
||||
|
||||
/**
|
||||
* Sets the IEDriverServer's logging {@linkplain Level level}.
|
||||
* @param {Level} level The logging level.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLogLevel(level: webdriver.logging.Level): Options;
|
||||
/**
|
||||
* Sets the IP address of the driver's host adapter.
|
||||
* @param {string} host The IP address to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setHost(host: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the IP address of the driver's host adapter.
|
||||
* @param {string} host The IP address to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setHost(host: string): Options;
|
||||
/**
|
||||
* Sets the path of the temporary data directory to use.
|
||||
* @param {string} path The log file path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setExtractPath(path: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the path of the temporary data directory to use.
|
||||
* @param {string} path The log file path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setExtractPath(path: string): Options;
|
||||
/**
|
||||
* Sets whether the driver should start in silent mode.
|
||||
* @param {boolean} silent Whether to run in silent mode.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
silent(silent: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets whether the driver should start in silent mode.
|
||||
* @param {boolean} silent Whether to run in silent mode.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
silent(silent: boolean): Options;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link capabilities.Capabilities}
|
||||
* object.
|
||||
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
|
||||
* merge these options into, if any.
|
||||
* @return {!capabilities.Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): 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;
|
||||
}
|
||||
|
||||
Vendored
+537
-2063
File diff suppressed because it is too large
Load Diff
Vendored
+140
@@ -0,0 +1,140 @@
|
||||
import { Locator, WebDriver } from '../';
|
||||
|
||||
/**
|
||||
* Typings for lib/by.js
|
||||
* Describes a mechanism for locating an element on the page.
|
||||
* @final
|
||||
*/
|
||||
export class By {
|
||||
/**
|
||||
* @param {string} using the name of the location strategy to use.
|
||||
* @param {string} value the value to search for.
|
||||
*/
|
||||
constructor(using: string, value: string);
|
||||
|
||||
using: string;
|
||||
value: string;
|
||||
|
||||
/**
|
||||
* Locates elements that have a specific class name.
|
||||
*
|
||||
* @param {string} name The class name to search for.
|
||||
* @return {!By} The new locator.
|
||||
* @see http://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes
|
||||
* @see http://www.w3.org/TR/CSS2/selector.html#class-html
|
||||
*/
|
||||
static className(name: string): By;
|
||||
|
||||
/**
|
||||
* Locates elements using a CSS selector.
|
||||
*
|
||||
* @param {string} selector The CSS selector to use.
|
||||
* @return {!By} The new locator.
|
||||
* @see http://www.w3.org/TR/CSS2/selector.html
|
||||
*/
|
||||
static css(selector: string): By;
|
||||
|
||||
/**
|
||||
* Locates eleemnts by the ID attribute. This locator uses the CSS selector
|
||||
* `*[id='$ID']`, _not_ `document.getElementById`.
|
||||
*
|
||||
* @param {string} id The ID to search for.
|
||||
* @return {!By} The new locator.
|
||||
*/
|
||||
static id(id: string): By;
|
||||
|
||||
/**
|
||||
* Locates link elements whose
|
||||
* {@linkplain WebElement#getText visible text} matches the given
|
||||
* string.
|
||||
*
|
||||
* @param {string} text The link text to search for.
|
||||
* @return {!By} The new locator.
|
||||
*/
|
||||
static linkText(text: string): By;
|
||||
|
||||
/**
|
||||
* Locates an elements by evaluating a
|
||||
* {@linkplain WebDriver#executeScript JavaScript expression}.
|
||||
* The result of this expression must be an element or list of elements.
|
||||
*
|
||||
* @param {!(string|Function)} script The script to execute.
|
||||
* @param {...*} var_args The arguments to pass to the script.
|
||||
* @return {function(!./WebDriver): !./Promise}
|
||||
* A new JavaScript-based locator function.
|
||||
*/
|
||||
static js(script: string|Function, ...var_args: any[]): (webdriver: WebDriver) => Promise<any>;
|
||||
|
||||
/**
|
||||
* Locates elements whose `name` attribute has the given value.
|
||||
*
|
||||
* @param {string} name The name attribute to search for.
|
||||
* @return {!By} The new locator.
|
||||
*/
|
||||
static name(name: string): By;
|
||||
|
||||
/**
|
||||
* Locates link elements whose
|
||||
* {@linkplain WebElement#getText visible text} contains the given
|
||||
* substring.
|
||||
*
|
||||
* @param {string} text The substring to check for in a link's visible text.
|
||||
* @return {!By} The new locator.
|
||||
*/
|
||||
static partialLinkText(text: string): By;
|
||||
|
||||
/**
|
||||
* Locates elements with a given tag name.
|
||||
*
|
||||
* @param {string} name The tag name to search for.
|
||||
* @return {!By} The new locator.
|
||||
* @deprecated Use {@link By.css() By.css(tagName)} instead.
|
||||
*/
|
||||
static tagName(name: string): By;
|
||||
|
||||
/**
|
||||
* Locates elements matching a XPath selector. Care should be taken when
|
||||
* using an XPath selector with a {@link WebElement} as WebDriver
|
||||
* will respect the context in the specified in the selector. For example,
|
||||
* given the selector `//div`, WebDriver will search from the document root
|
||||
* regardless of whether the locator was used with a WebElement.
|
||||
*
|
||||
* @param {string} xpath The XPath selector to use.
|
||||
* @return {!By} The new locator.
|
||||
* @see http://www.w3.org/TR/xpath/
|
||||
*/
|
||||
static xpath(xpath: string): By;
|
||||
|
||||
/** @override */
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Short-hand expressions for the primary element locator strategies.
|
||||
* For example the following two statements are equivalent:
|
||||
*
|
||||
* var e1 = driver.findElement(By.id('foo'));
|
||||
* var e2 = driver.findElement({id: 'foo'});
|
||||
*
|
||||
* Care should be taken when using JavaScript minifiers (such as the
|
||||
* Closure compiler), as locator hashes will always be parsed using
|
||||
* the un-obfuscated properties listed.
|
||||
*
|
||||
* @typedef {(
|
||||
* {className: string}|
|
||||
* {css: string}|
|
||||
* {id: string}|
|
||||
* {js: string}|
|
||||
* {linkText: string}|
|
||||
* {name: string}|
|
||||
* {partialLinkText: string}|
|
||||
* {tagName: string}|
|
||||
* {xpath: string})}
|
||||
*/
|
||||
export type ByHash = {
|
||||
className: string
|
||||
} | {css: string} |
|
||||
{id: string} | {js: string} | {linkText: string} | {name: string} | {partialLinkText: string} |
|
||||
{tagName: string} | {xpath: string};
|
||||
|
||||
export function checkedLocator(locator: Locator): By;
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* An enumeration of valid command string.
|
||||
*/
|
||||
export interface ICommandName {
|
||||
GET_SERVER_STATUS: string;
|
||||
|
||||
NEW_SESSION: string;
|
||||
GET_SESSIONS: string;
|
||||
DESCRIBE_SESSION: string;
|
||||
|
||||
CLOSE: string;
|
||||
QUIT: string;
|
||||
|
||||
GET_CURRENT_URL: string;
|
||||
GET: string;
|
||||
GO_BACK: string;
|
||||
GO_FORWARD: string;
|
||||
REFRESH: string;
|
||||
|
||||
ADD_COOKIE: string;
|
||||
GET_COOKIE: string;
|
||||
GET_ALL_COOKIES: string;
|
||||
DELETE_COOKIE: string;
|
||||
DELETE_ALL_COOKIES: string;
|
||||
|
||||
GET_ACTIVE_ELEMENT: string;
|
||||
FIND_ELEMENT: string;
|
||||
FIND_ELEMENTS: string;
|
||||
FIND_CHILD_ELEMENT: string;
|
||||
FIND_CHILD_ELEMENTS: string;
|
||||
|
||||
CLEAR_ELEMENT: string;
|
||||
CLICK_ELEMENT: string;
|
||||
SEND_KEYS_TO_ELEMENT: string;
|
||||
SUBMIT_ELEMENT: string;
|
||||
|
||||
GET_CURRENT_WINDOW_HANDLE: string;
|
||||
GET_WINDOW_HANDLES: string;
|
||||
GET_WINDOW_POSITION: string;
|
||||
SET_WINDOW_POSITION: string;
|
||||
GET_WINDOW_SIZE: string;
|
||||
SET_WINDOW_SIZE: string;
|
||||
MAXIMIZE_WINDOW: string;
|
||||
|
||||
SWITCH_TO_WINDOW: string;
|
||||
SWITCH_TO_FRAME: string;
|
||||
GET_PAGE_SOURCE: string;
|
||||
GET_TITLE: string;
|
||||
|
||||
EXECUTE_SCRIPT: string;
|
||||
EXECUTE_ASYNC_SCRIPT: string;
|
||||
|
||||
GET_ELEMENT_TEXT: string;
|
||||
GET_ELEMENT_TAG_NAME: string;
|
||||
IS_ELEMENT_SELECTED: string;
|
||||
IS_ELEMENT_ENABLED: string;
|
||||
IS_ELEMENT_DISPLAYED: string;
|
||||
GET_ELEMENT_LOCATION: string;
|
||||
GET_ELEMENT_LOCATION_IN_VIEW: string;
|
||||
GET_ELEMENT_SIZE: string;
|
||||
GET_ELEMENT_ATTRIBUTE: string;
|
||||
GET_ELEMENT_VALUE_OF_CSS_PROPERTY: string;
|
||||
ELEMENT_EQUALS: string;
|
||||
|
||||
SCREENSHOT: string;
|
||||
IMPLICITLY_WAIT: string;
|
||||
SET_SCRIPT_TIMEOUT: string;
|
||||
SET_TIMEOUT: string;
|
||||
|
||||
ACCEPT_ALERT: string;
|
||||
DISMISS_ALERT: string;
|
||||
GET_ALERT_TEXT: string;
|
||||
SET_ALERT_TEXT: string;
|
||||
|
||||
EXECUTE_SQL: string;
|
||||
GET_LOCATION: string;
|
||||
SET_LOCATION: string;
|
||||
GET_APP_CACHE: string;
|
||||
GET_APP_CACHE_STATUS: string;
|
||||
CLEAR_APP_CACHE: string;
|
||||
IS_BROWSER_ONLINE: string;
|
||||
SET_BROWSER_ONLINE: string;
|
||||
|
||||
GET_LOCAL_STORAGE_ITEM: string;
|
||||
GET_LOCAL_STORAGE_KEYS: string;
|
||||
SET_LOCAL_STORAGE_ITEM: string;
|
||||
REMOVE_LOCAL_STORAGE_ITEM: string;
|
||||
CLEAR_LOCAL_STORAGE: string;
|
||||
GET_LOCAL_STORAGE_SIZE: string;
|
||||
|
||||
GET_SESSION_STORAGE_ITEM: string;
|
||||
GET_SESSION_STORAGE_KEYS: string;
|
||||
SET_SESSION_STORAGE_ITEM: string;
|
||||
REMOVE_SESSION_STORAGE_ITEM: string;
|
||||
CLEAR_SESSION_STORAGE: string;
|
||||
GET_SESSION_STORAGE_SIZE: string;
|
||||
|
||||
SET_SCREEN_ORIENTATION: string;
|
||||
GET_SCREEN_ORIENTATION: string;
|
||||
|
||||
// These belong to the Advanced user interactions - an element is
|
||||
// optional for these commands.
|
||||
CLICK: string;
|
||||
DOUBLE_CLICK: string;
|
||||
MOUSE_DOWN: string;
|
||||
MOUSE_UP: string;
|
||||
MOVE_TO: string;
|
||||
SEND_KEYS_TO_ACTIVE_ELEMENT: string;
|
||||
|
||||
// These belong to the Advanced Touch API
|
||||
TOUCH_SINGLE_TAP: string;
|
||||
TOUCH_DOWN: string;
|
||||
TOUCH_UP: string;
|
||||
TOUCH_MOVE: string;
|
||||
TOUCH_SCROLL: string;
|
||||
TOUCH_DOUBLE_TAP: string;
|
||||
TOUCH_LONG_PRESS: string;
|
||||
TOUCH_FLICK: string;
|
||||
|
||||
GET_AVAILABLE_LOG_TYPES: string;
|
||||
GET_LOG: string;
|
||||
GET_SESSION_LOGS: string;
|
||||
|
||||
UPLOAD_FILE: string;
|
||||
|
||||
ACTIONS: string;
|
||||
CLEAR_ACTIONS: string;
|
||||
|
||||
LEGACY_ACTION_CLICK: string;
|
||||
LEGACY_ACTION_DOUBLE_CLICK: string;
|
||||
LEGACY_ACTION_MOUSE_DOWN: string;
|
||||
LEGACY_ACTION_MOUSE_UP: string;
|
||||
LEGACY_ACTION_MOUSE_MOVE: string;
|
||||
LEGACY_ACTION_SEND_KEYS: string;
|
||||
LEGACY_ACTION_TOUCH_DOWN: string;
|
||||
LEGACY_ACTION_TOUCH_UP: string;
|
||||
LEGACY_ACTION_TOUCH_MOVE: string;
|
||||
LEGACY_ACTION_TOUCH_SCROLL: string;
|
||||
LEGACY_ACTION_TOUCH_LONG_PRESS: string;
|
||||
LEGACY_ACTION_TOUCH_FLICK: string;
|
||||
LEGACY_ACTION_TOUCH_SINGLE_TAP: string;
|
||||
LEGACY_ACTION_TOUCH_DOUBLE_TAP: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The names of Command-s
|
||||
*/
|
||||
export const Name: ICommandName;
|
||||
|
||||
/**
|
||||
* Describes a command to be executed by the WebDriverJS framework.
|
||||
* @param {!CommandName} name The name of this command.
|
||||
* @constructor
|
||||
*/
|
||||
export class Command {
|
||||
// region Constructors
|
||||
|
||||
/**
|
||||
* @param {!CommandName} name The name of this command.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(name: string);
|
||||
|
||||
// endregion
|
||||
|
||||
// region Methods
|
||||
|
||||
/**
|
||||
* @return {!CommandName} This command's name.
|
||||
*/
|
||||
getName(): string;
|
||||
|
||||
/**
|
||||
* Sets a parameter to send with this command.
|
||||
* @param {string} name The parameter name.
|
||||
* @param {*} value The parameter value.
|
||||
* @return {!Command} A self reference.
|
||||
*/
|
||||
setParameter(name: string, value: any): Command;
|
||||
|
||||
/**
|
||||
* Sets the parameters for this command.
|
||||
* @param {!Object.<*>} parameters The command parameters.
|
||||
* @return {!Command} A self reference.
|
||||
*/
|
||||
setParameters(parameters: any): Command;
|
||||
|
||||
/**
|
||||
* Returns a named command parameter.
|
||||
* @param {string} key The parameter key to look up.
|
||||
* @return {*} The parameter value, or undefined if it has not been set.
|
||||
*/
|
||||
getParameter(key: string): any;
|
||||
|
||||
/**
|
||||
* @return {!Object.<*>} The parameters to send with this command.
|
||||
*/
|
||||
getParameters(): any;
|
||||
|
||||
// endregion
|
||||
}
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
import { Executor, ILocation, WebDriver, WebElement } from '../';
|
||||
|
||||
/**
|
||||
* Defines the reference point from which to compute offsets for
|
||||
* {@linkplain ./input.Pointer#move pointer move} actions.
|
||||
*/
|
||||
export enum Origin {
|
||||
/** Compute offsets relative to the pointer's current position. */
|
||||
POINTER = 'pointer',
|
||||
/** Compute offsets relative to the viewport. */
|
||||
VIEWPORT = 'viewport',
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration of the buttons used in the advanced interactions API.
|
||||
*/
|
||||
export enum Button {
|
||||
LEFT = 0,
|
||||
MIDDLE = 1,
|
||||
RIGHT = 2,
|
||||
}
|
||||
|
||||
export interface IKey {
|
||||
NULL: string;
|
||||
CANCEL: string; // ^break
|
||||
HELP: string;
|
||||
BACK_SPACE: string;
|
||||
TAB: string;
|
||||
CLEAR: string;
|
||||
RETURN: string;
|
||||
ENTER: string;
|
||||
SHIFT: string;
|
||||
CONTROL: string;
|
||||
ALT: string;
|
||||
PAUSE: string;
|
||||
ESCAPE: string;
|
||||
SPACE: string;
|
||||
PAGE_UP: string;
|
||||
PAGE_DOWN: string;
|
||||
END: string;
|
||||
HOME: string;
|
||||
ARROW_LEFT: string;
|
||||
LEFT: string;
|
||||
ARROW_UP: string;
|
||||
UP: string;
|
||||
ARROW_RIGHT: string;
|
||||
RIGHT: string;
|
||||
ARROW_DOWN: string;
|
||||
DOWN: string;
|
||||
INSERT: string;
|
||||
DELETE: string;
|
||||
SEMICOLON: string;
|
||||
EQUALS: string;
|
||||
|
||||
NUMPAD0: string; // number pad keys
|
||||
NUMPAD1: string;
|
||||
NUMPAD2: string;
|
||||
NUMPAD3: string;
|
||||
NUMPAD4: string;
|
||||
NUMPAD5: string;
|
||||
NUMPAD6: string;
|
||||
NUMPAD7: string;
|
||||
NUMPAD8: string;
|
||||
NUMPAD9: string;
|
||||
MULTIPLY: string;
|
||||
ADD: string;
|
||||
SEPARATOR: string;
|
||||
SUBTRACT: string;
|
||||
DECIMAL: string;
|
||||
DIVIDE: string;
|
||||
|
||||
F1: string; // function keys
|
||||
F2: string;
|
||||
F3: string;
|
||||
F4: string;
|
||||
F5: string;
|
||||
F6: string;
|
||||
F7: string;
|
||||
F8: string;
|
||||
F9: string;
|
||||
F10: string;
|
||||
F11: string;
|
||||
F12: string;
|
||||
|
||||
COMMAND: string; // Apple command key
|
||||
META: string; // alias for Windows key
|
||||
|
||||
/**
|
||||
* Simulate pressing many keys at once in a 'chord'. Takes a sequence of
|
||||
* keys or strings, appends each of the values to a string,
|
||||
* and adds the chord termination key ({@link Key.NULL}) and returns
|
||||
* the resulting string.
|
||||
*
|
||||
* Note: when the low-level webdriver key handlers see Keys.NULL, active
|
||||
* modifier keys (CTRL/ALT/SHIFT/etc) release via a keyup event.
|
||||
*
|
||||
* @param {...string} var_args The key sequence to concatenate.
|
||||
* @return {string} The null-terminated key sequence.
|
||||
*/
|
||||
chord(...var_args: Array<string|IKey>): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Representations of pressable keys that aren't text. These are stored in
|
||||
* the Unicode PUA (Private Use Area) code points, 0xE000-0xF8FF. Refer to
|
||||
* http://www.google.com.au/search?&q=unicode+pua&btnG=Search
|
||||
*
|
||||
* @enum {string}
|
||||
*/
|
||||
export const Key: IKey;
|
||||
|
||||
export interface IDirection {
|
||||
x?: number|undefined;
|
||||
y?: number|undefined;
|
||||
duration?: number|undefined;
|
||||
origin?: Origin|WebElement|undefined;
|
||||
}
|
||||
|
||||
export const INTERNAL_COMPUTE_OFFSET_SCRIPT: string;
|
||||
|
||||
export class Device { constructor(type: string, id: string); }
|
||||
|
||||
export class Pointer extends Device {}
|
||||
export class Keyboard extends Device {}
|
||||
|
||||
/**
|
||||
* Class for defining sequences of complex user interactions. Each sequence
|
||||
* will not be executed until {@link #perform} is called.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* new Actions(driver).
|
||||
* keyDown(Key.SHIFT).
|
||||
* click(element1).
|
||||
* click(element2).
|
||||
* dragAndDrop(element3, element4).
|
||||
* keyUp(Key.SHIFT).
|
||||
* perform();
|
||||
*
|
||||
*/
|
||||
export class Actions {
|
||||
// region Constructors
|
||||
|
||||
constructor(executor: Executor, options?: {async: boolean,
|
||||
bridge: boolean}|{async: boolean}|{bridge: boolean});
|
||||
|
||||
// endregion
|
||||
|
||||
// region Methods
|
||||
keyboard(): Keyboard;
|
||||
mouse(): Pointer;
|
||||
/**
|
||||
* Executes this action sequence.
|
||||
* @return {!Promise} A promise that will be resolved once
|
||||
* this sequence has completed.
|
||||
*/
|
||||
clear(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Executes this action sequence.
|
||||
* @return {!Promise} A promise that will be resolved once
|
||||
* this sequence has completed.
|
||||
*/
|
||||
perform(): Promise<void>;
|
||||
|
||||
pause(duration?: number|Device, ...devices: Device[]): Actions;
|
||||
|
||||
/**
|
||||
* Inserts an action to press a mouse button at the mouse's current location.
|
||||
* Defaults to `LEFT`.
|
||||
*/
|
||||
press(button?: Button): Actions;
|
||||
|
||||
/**
|
||||
* Inserts an action to release a mouse button at the mouse's current
|
||||
* location. Defaults to `LEFT`.
|
||||
*/
|
||||
release(button?: Button): Actions;
|
||||
|
||||
/**
|
||||
* Inserts an action for moving the mouse `x` and `y` pixels relative to the
|
||||
* specified `origin`. The `origin` may be defined as the mouse's
|
||||
* {@linkplain ./input.Origin.POINTER current position}, the
|
||||
* {@linkplain ./input.Origin.VIEWPORT viewport}, or the center of a specific
|
||||
* {@linkplain ./webdriver.WebElement WebElement}.
|
||||
*
|
||||
* You may adjust how long the remote end should take, in milliseconds, to
|
||||
* perform the move using the `duration` parameter (defaults to 100 ms).
|
||||
* The number of incremental move events generated over this duration is an
|
||||
* implementation detail for the remote end.
|
||||
*
|
||||
* Defaults to moving the mouse to the top-left
|
||||
* corner of the viewport over 100ms.
|
||||
*/
|
||||
move(direction: IDirection): Actions;
|
||||
|
||||
/**
|
||||
* Moves the mouse. The location to move to may be specified in terms of the
|
||||
* mouse's current location, an offset relative to the top-left corner of an
|
||||
* element, or an element (in which case the middle of the element is used).
|
||||
*
|
||||
* @param {(!./WebElement|{x: number, y: number})} location The
|
||||
* location to drag to, as either another WebElement or an offset in
|
||||
* pixels.
|
||||
* @param {{x: number, y: number}=} opt_offset If the target {@code location}
|
||||
* is defined as a {@link ./WebElement}, this parameter defines
|
||||
* an offset within that element. The offset should be specified in pixels
|
||||
* relative to the top-left corner of the element's bounding box. If
|
||||
* omitted, the element's center will be used as the target offset.
|
||||
* @return {!Actions} A self reference.
|
||||
*/
|
||||
mouseMove(location: WebElement|ILocation, opt_offset?: ILocation): Actions;
|
||||
|
||||
/**
|
||||
* Presses a mouse button. The mouse button will not be released until
|
||||
* {@link #mouseUp} is called, regardless of whether that call is made in this
|
||||
* sequence or another. The behavior for out-of-order events (e.g. mouseDown,
|
||||
* click) is undefined.
|
||||
*
|
||||
* If an element is provided, the mouse will first be moved to the center
|
||||
* of that element. This is equivalent to:
|
||||
*
|
||||
* sequence.mouseMove(element).mouseDown()
|
||||
*
|
||||
* Warning: this method currently only supports the left mouse button. See
|
||||
* [issue 4047](http://code.google.com/p/selenium/issues/detail?id=4047).
|
||||
*
|
||||
* @param {(./WebElement|input.Button)=} opt_elementOrButton Either
|
||||
* the element to interact with or the button to click with.
|
||||
* Defaults to {@link input.Button.LEFT} if neither an element nor
|
||||
* button is specified.
|
||||
* @param {input.Button=} opt_button The button to use. Defaults to
|
||||
* {@link input.Button.LEFT}. Ignored if a button is provided as the
|
||||
* first argument.
|
||||
* @return {!Actions} A self reference.
|
||||
*/
|
||||
mouseDown(opt_elementOrButton?: WebElement|string, opt_button?: string): Actions;
|
||||
|
||||
/**
|
||||
* Releases a mouse button. Behavior is undefined for calling this function
|
||||
* without a previous call to {@link #mouseDown}.
|
||||
*
|
||||
* If an element is provided, the mouse will first be moved to the center
|
||||
* of that element. This is equivalent to:
|
||||
*
|
||||
* sequence.mouseMove(element).mouseUp()
|
||||
*
|
||||
* Warning: this method currently only supports the left mouse button. See
|
||||
* [issue 4047](http://code.google.com/p/selenium/issues/detail?id=4047).
|
||||
*
|
||||
* @param {(./WebElement|input.Button)=} opt_elementOrButton Either
|
||||
* the element to interact with or the button to click with.
|
||||
* Defaults to {@link input.Button.LEFT} if neither an element nor
|
||||
* button is specified.
|
||||
* @param {input.Button=} opt_button The button to use. Defaults to
|
||||
* {@link input.Button.LEFT}. Ignored if a button is provided as the
|
||||
* first argument.
|
||||
* @return {!Actions} A self reference.
|
||||
*/
|
||||
mouseUp(opt_elementOrButton?: WebElement|string, opt_button?: string): Actions;
|
||||
|
||||
/**
|
||||
* Convenience function for performing a 'drag and drop' manuever. The target
|
||||
* element may be moved to the location of another element, or by an offset (in
|
||||
* pixels).
|
||||
*/
|
||||
dragAndDrop(from: WebElement, to?: WebElement|{x?: number | string, y?: number|string}|null):
|
||||
Actions;
|
||||
|
||||
/**
|
||||
* Clicks a mouse button.
|
||||
*
|
||||
* If an element is provided, the mouse will first be moved to the center
|
||||
* of that element. This is equivalent to:
|
||||
*
|
||||
* sequence.mouseMove(element).click()
|
||||
*
|
||||
* @param {(./WebElement|input.Button)=} opt_elementOrButton Either
|
||||
* the element to interact with or the button to click with.
|
||||
* Defaults to {@link input.Button.LEFT} if neither an element nor
|
||||
* button is specified.
|
||||
* @param {input.Button=} opt_button The button to use. Defaults to
|
||||
* {@link input.Button.LEFT}. Ignored if a button is provided as the
|
||||
* first argument.
|
||||
* @return {!Actions} A self reference.
|
||||
*/
|
||||
click(opt_elementOrButton?: WebElement|string, opt_button?: string): Actions;
|
||||
|
||||
/**
|
||||
* Double-clicks a mouse button.
|
||||
*
|
||||
* If an element is provided, the mouse will first be moved to the center of
|
||||
* that element. This is equivalent to:
|
||||
*
|
||||
* sequence.mouseMove(element).doubleClick()
|
||||
*
|
||||
* Warning: this method currently only supports the left mouse button. See
|
||||
* [issue 4047](http://code.google.com/p/selenium/issues/detail?id=4047).
|
||||
*
|
||||
* @param {(./WebElement|input.Button)=} opt_elementOrButton Either
|
||||
* the element to interact with or the button to click with.
|
||||
* Defaults to {@link input.Button.LEFT} if neither an element nor
|
||||
* button is specified.
|
||||
* @param {input.Button=} opt_button The button to use. Defaults to
|
||||
* {@link input.Button.LEFT}. Ignored if a button is provided as the
|
||||
* first argument.
|
||||
* @return {!Actions} A self reference.
|
||||
*/
|
||||
doubleClick(opt_elementOrButton?: WebElement|string, opt_button?: string): Actions;
|
||||
|
||||
/**
|
||||
* Short-hand for performing a simple right-click (down/up) with the mouse.
|
||||
*
|
||||
* @param {./webdriver.WebElement=} element If specified, the mouse will
|
||||
* first be moved to the center of the element before performing the
|
||||
* click.
|
||||
* @return {!Actions} a self reference.
|
||||
*/
|
||||
contextClick(opt_elementOrButton?: WebElement|string): Actions;
|
||||
|
||||
/**
|
||||
* Performs a modifier key press. The modifier key is <em>not released</em>
|
||||
* until {@link #keyUp} or {@link #sendKeys} is called. The key press will be
|
||||
* targetted at the currently focused element.
|
||||
* @param {!Key} key The modifier key to push. Must be one of
|
||||
* {ALT, CONTROL, SHIFT, COMMAND, META}.
|
||||
* @return {!Actions} A self reference.
|
||||
* @throws {Error} If the key is not a valid modifier key.
|
||||
*/
|
||||
keyDown(key: string): Actions;
|
||||
|
||||
/**
|
||||
* Performs a modifier key release. The release is targetted at the currently
|
||||
* focused element.
|
||||
* @param {!Key} key The modifier key to release. Must be one of
|
||||
* {ALT, CONTROL, SHIFT, COMMAND, META}.
|
||||
* @return {!Actions} A self reference.
|
||||
* @throws {Error} If the key is not a valid modifier key.
|
||||
*/
|
||||
keyUp(key: string): Actions;
|
||||
|
||||
/**
|
||||
* Simulates typing multiple keys. Each modifier key encountered in the
|
||||
* sequence will not be released until it is encountered again. All key events
|
||||
* will be targeted at the currently focused element.
|
||||
*
|
||||
* @param {...(string|!input.Key|!Array<(string|!input.Key)>)} var_args
|
||||
* The keys to type.
|
||||
* @return {!Actions} A self reference.
|
||||
* @throws {Error} If the key is not a valid modifier key.
|
||||
*/
|
||||
sendKeys(...var_args: Array<string|Promise<string>>): Actions;
|
||||
|
||||
// endregion
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
import { EventEmitter } from '../';
|
||||
|
||||
/**
|
||||
* promise
|
||||
*/
|
||||
|
||||
export namespace promise {
|
||||
// region Functions
|
||||
|
||||
/**
|
||||
* Determines whether a {@code value} should be treated as a promise.
|
||||
* Any object whose 'then' property is a function will be considered a
|
||||
* promise.
|
||||
*/
|
||||
function isPromise(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Creates a promise that will be resolved at a set time in the future.
|
||||
*/
|
||||
function delayed(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function filter<T, V>(
|
||||
arr: T[]|Promise<T[]>, fn: (element: T, index: number, array: T[]) => V,
|
||||
// tslint:disable-next-line:no-any The type of archaic `self` adds no
|
||||
// value
|
||||
optSelf?: any): Promise<V[]>;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// tslint:disable-next-line:no-any The type of archaic `self` adds no value
|
||||
function map<T, V>(
|
||||
arr: T[]|Promise<T[]>, fn: (self: any, type: T, index: number, array: T[]) => V,
|
||||
optSelf?: any): Promise<V[]>;
|
||||
|
||||
/**
|
||||
* Wraps a function that expects a node-style callback as its final
|
||||
* argument. This callback expects two arguments: an error value (which will
|
||||
* be null if the call succeeded), and the success value as the second
|
||||
* argument. The callback will the resolve or reject the returned promise,
|
||||
* based on its arguments.
|
||||
*/
|
||||
// tslint:disable-next-line:no-any Variable args have variable types.
|
||||
function checkedNodeCall<T>(fn: Function, ...varArgs: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
* promise.fullyResolved(value); // Stack overflow.
|
||||
*/
|
||||
// tslint:disable-next-line:no-any Complex relation between input and output
|
||||
function fullyResolved(value: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* Registers a listener to invoke when a 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:
|
||||
*
|
||||
* // Synchronous API:
|
||||
* try {
|
||||
* doSynchronousWork();
|
||||
* } finally {
|
||||
* cleanUp();
|
||||
* }
|
||||
*
|
||||
* // Asynchronous promise API:
|
||||
* doAsynchronousWork().finally(cleanUp);
|
||||
*
|
||||
* __Note:__ 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:
|
||||
*
|
||||
* try {
|
||||
* throw Error('one');
|
||||
* } finally {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* }
|
||||
*
|
||||
* let p = Promise.reject(Error('one'));
|
||||
* promise.finally(p, function() {
|
||||
* throw Error('two'); // Hides Error: one
|
||||
* });
|
||||
*/
|
||||
function thenFinally<R>(promise: any, callback: () => R | Promise<R>): Promise<R>;
|
||||
|
||||
// endregion
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
import { Alert, By, ByHash, Condition, Locator, WebDriver, WebElement, WebElementCondition } from '../';
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* 1. a numeric index into
|
||||
* [window.frames](https://developer.mozilla.org/en-US/docs/Web/API/Window.frames)
|
||||
* for the currently selected frame.
|
||||
* 2. a {@link ./WebElement}, which must reference a FRAME or IFRAME
|
||||
* element on the current page.
|
||||
* 3. 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|./WebElement|By|function(!./WebDriver): !./WebElement)} frame
|
||||
* The frame identifier.
|
||||
* @return {!Condition<boolean>} A new condition.
|
||||
*/
|
||||
export function ableToSwitchToFrame(
|
||||
frame: number|WebElement|By|((webdriver: WebDriver) => WebElement)|ByHash): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* 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<!./Alert>} The new condition.
|
||||
*/
|
||||
export function alertIsPresent(): Condition<Alert>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be disabled.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#isEnabled
|
||||
*/
|
||||
export function elementIsDisabled(element: WebElement): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be enabled.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#isEnabled
|
||||
*/
|
||||
export function elementIsEnabled(element: WebElement): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be deselected.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#isSelected
|
||||
*/
|
||||
export function elementIsNotSelected(element: WebElement): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be in the DOM,
|
||||
* yet not visible to the user.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#isDisplayed
|
||||
*/
|
||||
export function elementIsNotVisible(element: WebElement): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be selected.
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#isSelected
|
||||
*/
|
||||
export function elementIsSelected(element: WebElement): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to become visible.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#isDisplayed
|
||||
*/
|
||||
export function elementIsVisible(element: WebElement): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will loop until an element is
|
||||
* {@link ./WebDriver#findElement found} with the given locator.
|
||||
*
|
||||
* @param {!(By|Function)} locator The locator to use.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
*/
|
||||
export function elementLocated(locator: Locator): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element's
|
||||
* {@link WebDriver#getText visible text} to contain the given
|
||||
* substring.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @param {string} substr The substring to search for.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#getText
|
||||
*/
|
||||
export function elementTextContains(element: WebElement, substr: string): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element's
|
||||
* {@link WebDriver#getText visible text} to match the given
|
||||
* {@code text} exactly.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @param {string} text The expected text.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#getText
|
||||
*/
|
||||
export function elementTextIs(element: WebElement, text: string): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element's
|
||||
* {@link WebDriver#getText visible text} to match a regular
|
||||
* expression.
|
||||
*
|
||||
* @param {!WebElement} element The element to test.
|
||||
* @param {!RegExp} regex The regular expression to test against.
|
||||
* @return {!WebElementCondition} The new condition.
|
||||
* @see WebDriver#getText
|
||||
*/
|
||||
export function elementTextMatches(element: WebElement, regex: RegExp): WebElementCondition;
|
||||
|
||||
/**
|
||||
* Creates a condition that will loop until at least one element is
|
||||
* {@link WebDriver#findElement found} with the given locator.
|
||||
*
|
||||
* @param {!(Locator|By.Hash|Function)} locator The locator
|
||||
* to use.
|
||||
* @return {!Condition.<!Array.<!WebElement>>} The new
|
||||
* condition.
|
||||
*/
|
||||
export function elementsLocated(locator: Locator): Condition<WebElement[]>;
|
||||
|
||||
/**
|
||||
* 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 {!WebElement} element The element that should become stale.
|
||||
* @return {!Condition<boolean>} The new condition.
|
||||
*/
|
||||
export function stalenessOf(element: WebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* 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 {!Condition.<boolean>} The new condition.
|
||||
*/
|
||||
export function titleContains(substr: string): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* 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 {!Condition<boolean>} The new condition.
|
||||
*/
|
||||
export function titleIs(title: string): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* 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 {!Condition.<boolean>} The new condition.
|
||||
*/
|
||||
export function titleMatches(regex: RegExp): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the current page's url to contain
|
||||
* the given substring.
|
||||
*
|
||||
* @param {string} substrUrl The substring that should be present in the
|
||||
* current URL.
|
||||
* @return {!Condition<boolean>} The new condition.
|
||||
*/
|
||||
export function urlContains(substrUrl: string): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the current page's url to match the
|
||||
* given value.
|
||||
*
|
||||
* @param {string} url The expected page url.
|
||||
* @return {!Condition<boolean>} The new condition.
|
||||
*/
|
||||
export function urlIs(url: string): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the current page's url to match the
|
||||
* given regular expression.
|
||||
*
|
||||
* @param {!RegExp} regex The regular expression to test against.
|
||||
* @return {!Condition<boolean>} The new condition.
|
||||
*/
|
||||
export function urlMatches(regex: RegExp): Condition<boolean>;
|
||||
Vendored
+162
-170
@@ -6,7 +6,7 @@ import * as webdriver from './index';
|
||||
*
|
||||
* @record
|
||||
*/
|
||||
export interface ServiceOptions { }
|
||||
export interface ServiceOptions {}
|
||||
|
||||
/**
|
||||
* Manages the life and death of a native executable WebDriver server.
|
||||
@@ -17,144 +17,136 @@ export interface ServiceOptions { }
|
||||
* so that this class may be reused for multiple clients.
|
||||
*/
|
||||
export class DriverService {
|
||||
/**
|
||||
* @param {string} executable Path to the executable to run.
|
||||
* @param {!ServiceOptions} options Configuration options for the service.
|
||||
*/
|
||||
constructor(executable: string, options: ServiceOptions);
|
||||
/**
|
||||
* @param {string} executable Path to the executable to run.
|
||||
* @param {!ServiceOptions} options Configuration options for the service.
|
||||
*/
|
||||
constructor(executable: string, options: ServiceOptions);
|
||||
|
||||
/**
|
||||
* @return {!promise.Promise<string>} A promise that resolves to
|
||||
* the server's address.
|
||||
* @throws {Error} If the server has not been started.
|
||||
*/
|
||||
address(): webdriver.promise.Promise<string>;
|
||||
/**
|
||||
* @return {!promise.Promise<string>} A promise that resolves to
|
||||
* the server's address.
|
||||
* @throws {Error} If the server has not been started.
|
||||
*/
|
||||
address(): Promise<string>;
|
||||
|
||||
/**
|
||||
* Returns whether the underlying process is still running. This does not take
|
||||
* into account whether the process is in the process of shutting down.
|
||||
* @return {boolean} Whether the underlying service process is running.
|
||||
*/
|
||||
isRunning(): boolean;
|
||||
/**
|
||||
* Returns whether the underlying process is still running. This does not take
|
||||
* into account whether the process is in the process of shutting down.
|
||||
* @return {boolean} Whether the underlying service process is running.
|
||||
*/
|
||||
isRunning(): boolean;
|
||||
|
||||
/**
|
||||
* Starts the server if it is not already running.
|
||||
* @param {number=} opt_timeoutMs How long to wait, in milliseconds, for the
|
||||
* server to start accepting requests. Defaults to 30 seconds.
|
||||
* @return {!promise.Promise<string>} A promise that will resolve
|
||||
* to the server's base URL when it has started accepting requests. If the
|
||||
* timeout expires before the server has started, the promise will be
|
||||
* rejected.
|
||||
*/
|
||||
start(opt_timeoutMs?: number): webdriver.promise.Promise<string>;
|
||||
/**
|
||||
* Starts the server if it is not already running.
|
||||
* @param {number=} opt_timeoutMs How long to wait, in milliseconds, for the
|
||||
* server to start accepting requests. Defaults to 30 seconds.
|
||||
* @return {!promise.Promise<string>} A promise that will resolve
|
||||
* to the server's base URL when it has started accepting requests. If the
|
||||
* timeout expires before the server has started, the promise will be
|
||||
* rejected.
|
||||
*/
|
||||
start(opt_timeoutMs?: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* Stops the service if it is not currently running. This function will kill
|
||||
* the server immediately. To synchronize with the active control flow, use
|
||||
* {@link #stop()}.
|
||||
* @return {!promise.Promise} A promise that will be resolved when
|
||||
* the server has been stopped.
|
||||
*/
|
||||
kill(): webdriver.promise.Promise<any>;
|
||||
|
||||
/**
|
||||
* Schedules a task in the current control flow to stop the server if it is
|
||||
* currently running.
|
||||
* @return {!promise.Promise} A promise that will be resolved when
|
||||
* the server has been stopped.
|
||||
*/
|
||||
stop(): webdriver.promise.Promise<any>;
|
||||
/**
|
||||
* Stops the service if it is not currently running. This function will kill
|
||||
* the server immediately. To synchronize with the active control flow, use
|
||||
* {@link #stop()}.
|
||||
* @return {!promise.Promise} A promise that will be resolved when
|
||||
* the server has been stopped.
|
||||
*/
|
||||
kill(): Promise<any>;
|
||||
}
|
||||
|
||||
export namespace DriverService {
|
||||
/**
|
||||
* Creates {@link DriverService} objects that manage a WebDriver server in a
|
||||
* child process.
|
||||
*/
|
||||
class Builder {
|
||||
/**
|
||||
* Creates {@link DriverService} objects that manage a WebDriver server in a
|
||||
* child process.
|
||||
* @param {string} exe Path to the executable to use. This executable must
|
||||
* accept the `--port` flag for defining the port to start the server on.
|
||||
* @throws {Error} If the provided executable path does not exist.
|
||||
*/
|
||||
class Builder {
|
||||
/**
|
||||
* @param {string} exe Path to the executable to use. This executable must
|
||||
* accept the `--port` flag for defining the port to start the server on.
|
||||
* @throws {Error} If the provided executable path does not exist.
|
||||
*/
|
||||
constructor(exe: string);
|
||||
constructor(exe: string);
|
||||
|
||||
/**
|
||||
* Define additional command line arguments to use when starting the server.
|
||||
*
|
||||
* @param {...CommandLineFlag} var_args The arguments to include.
|
||||
* @return {!THIS} A self reference.
|
||||
* @this {THIS}
|
||||
* @template THIS
|
||||
*/
|
||||
addArguments(...var_args: string[]): this;
|
||||
/**
|
||||
* Define additional command line arguments to use when starting the server.
|
||||
*
|
||||
* @param {...CommandLineFlag} var_args The arguments to include.
|
||||
* @return {!THIS} A self reference.
|
||||
* @this {THIS}
|
||||
* @template THIS
|
||||
*/
|
||||
addArguments(...var_args: string[]): this;
|
||||
|
||||
/**
|
||||
* Sets the host name to access the server on. If specified, the
|
||||
* {@linkplain #setLoopback() loopback} setting will be ignored.
|
||||
*
|
||||
* @param {string} hostname
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setHostname(hostname: string): this;
|
||||
/**
|
||||
* Sets the host name to access the server on. If specified, the
|
||||
* {@linkplain #setLoopback() loopback} setting will be ignored.
|
||||
*
|
||||
* @param {string} hostname
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setHostname(hostname: string): this;
|
||||
|
||||
/**
|
||||
* Sets whether the service should be accessed at this host's loopback
|
||||
* address.
|
||||
*
|
||||
* @param {boolean} loopback
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setLoopback(loopback: boolean): this;
|
||||
/**
|
||||
* Sets whether the service should be accessed at this host's loopback
|
||||
* address.
|
||||
*
|
||||
* @param {boolean} loopback
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setLoopback(loopback: boolean): this;
|
||||
|
||||
/**
|
||||
* Sets the base path for WebDriver REST commands (e.g. "/wd/hub").
|
||||
* By default, the driver will accept commands relative to "/".
|
||||
*
|
||||
* @param {?string} basePath The base path to use, or `null` to use the
|
||||
* default.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setPath(basePath: string | null): this;
|
||||
/**
|
||||
* Sets the base path for WebDriver REST commands (e.g. "/wd/hub").
|
||||
* By default, the driver will accept commands relative to "/".
|
||||
*
|
||||
* @param {?string} basePath The base path to use, or `null` to use the
|
||||
* default.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setPath(basePath: string|null): this;
|
||||
|
||||
/**
|
||||
* Sets the port to start the server on.
|
||||
*
|
||||
* @param {number} port The port to use, or 0 for any free port.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
* @throws {Error} If an invalid port is specified.
|
||||
*/
|
||||
setPort(port: number): this;
|
||||
/**
|
||||
* Sets the port to start the server on.
|
||||
*
|
||||
* @param {number} port The port to use, or 0 for any free port.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
* @throws {Error} If an invalid port is specified.
|
||||
*/
|
||||
setPort(port: number): this;
|
||||
|
||||
/**
|
||||
* Defines the environment to start the server under. This setting will be
|
||||
* inherited by every browser session started by the server. By default, the
|
||||
* server will inherit the enviroment of the current process.
|
||||
*
|
||||
* @param {(Map<string, string>|Object<string, string>|null)} env The desired
|
||||
* environment to use, or `null` if the server should inherit the
|
||||
* current environment.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setEnvironment(env: Map<string, string> | {[name: string]: string} | null): this;
|
||||
/**
|
||||
* Defines the environment to start the server under. This setting will be
|
||||
* inherited by every browser session started by the server. By default, the
|
||||
* server will inherit the enviroment of the current process.
|
||||
*
|
||||
* @param {(Map<string, string>|Object<string, string>|null)} env The desired
|
||||
* environment to use, or `null` if the server should inherit the
|
||||
* current environment.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setEnvironment(env: Map<string, string>|{[name: string]: string}|null): this;
|
||||
|
||||
/**
|
||||
* IO configuration for the spawned server process. For more information,
|
||||
* refer to the documentation of `child_process.spawn`.
|
||||
*
|
||||
* @param {StdIoOptions} config The desired IO configuration.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
* @see https://nodejs.org/dist/latest-v4.x/docs/api/child_process.html#child_process_options_stdio
|
||||
*/
|
||||
setStdio(config: any): this;
|
||||
/**
|
||||
* IO configuration for the spawned server process. For more information,
|
||||
* refer to the documentation of `child_process.spawn`.
|
||||
*
|
||||
* @param {StdIoOptions} config The desired IO configuration.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
* @see https://nodejs.org/dist/latest-v4.x/docs/api/child_process.html#child_process_options_stdio
|
||||
*/
|
||||
setStdio(config: any): this;
|
||||
|
||||
/**
|
||||
* Creates a new DriverService using this instance's current configuration.
|
||||
*
|
||||
* @return {!DriverService} A new driver service.
|
||||
*/
|
||||
build(): DriverService;
|
||||
}
|
||||
/**
|
||||
* Creates a new DriverService using this instance's current configuration.
|
||||
*
|
||||
* @return {!DriverService} A new driver service.
|
||||
*/
|
||||
build(): DriverService;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,44 +155,44 @@ export namespace DriverService {
|
||||
* standalone Selenium server</a>.
|
||||
*/
|
||||
export class SeleniumServer extends DriverService {
|
||||
/**
|
||||
* @param {string} jar Path to the Selenium server jar.
|
||||
* @param {SeleniumServer.Options=} opt_options Configuration options for the
|
||||
* server.
|
||||
* @throws {Error} If the path to the Selenium jar is not specified or if an
|
||||
* invalid port is specified.
|
||||
**/
|
||||
constructor(jar: string, opt_options?: SeleniumServer.Options);
|
||||
/**
|
||||
* @param {string} jar Path to the Selenium server jar.
|
||||
* @param {SeleniumServer.Options=} opt_options Configuration options for the
|
||||
* server.
|
||||
* @throws {Error} If the path to the Selenium jar is not specified or if an
|
||||
* invalid port is specified.
|
||||
**/
|
||||
constructor(jar: string, opt_options?: SeleniumServer.Options);
|
||||
}
|
||||
|
||||
export namespace SeleniumServer {
|
||||
/**
|
||||
* Options for the Selenium server
|
||||
*/
|
||||
interface Options {
|
||||
/** Whether the server should only be accessed on this host's loopback address.*/
|
||||
loopback?: boolean;
|
||||
/**
|
||||
* Options for the Selenium server
|
||||
*/
|
||||
interface Options {
|
||||
/** Whether the server should only be accessed on this host's loopback address.*/
|
||||
loopback?: boolean;
|
||||
|
||||
/** The port to start the server on (must be > 0). If the port is provided
|
||||
as a promise, the service will wait for the promise to resolve before starting. */
|
||||
port?: number|webdriver.promise.IThenable<number>;
|
||||
/** The port to start the server on (must be > 0). If the port is provided
|
||||
as a promise, the service will wait for the promise to resolve before starting. */
|
||||
port?: number|Promise<number>;
|
||||
|
||||
/** The arguments to pass to the service. If a promise is provided, the
|
||||
service will wait for it to resolve before starting. */
|
||||
args?: string[]|webdriver.promise.IThenable<string[]>;
|
||||
/** The arguments to pass to the service. If a promise is provided, the
|
||||
service will wait for it to resolve before starting. */
|
||||
args?: string[]|Promise<string[]>;
|
||||
|
||||
/** The arguments to pass to the JVM. If a promise is provided, the service
|
||||
will wait for it to resolve before starting. */
|
||||
jvmArgs?: string[]|webdriver.promise.IThenable<string[]>;
|
||||
/** The arguments to pass to the JVM. If a promise is provided, the service
|
||||
will wait for it to resolve before starting. */
|
||||
jvmArgs?: string[]|Promise<string[]>;
|
||||
|
||||
/** The environment variables that should be visible to the server process.
|
||||
Defaults to inheriting the current process's environment.*/
|
||||
env?: {[key: string]: string};
|
||||
/** The environment variables that should be visible to the server process.
|
||||
Defaults to inheriting the current process's environment.*/
|
||||
env?: {[key: string]: string};
|
||||
|
||||
/** IO configuration for the spawned server process. For more information,
|
||||
refer to the documentation of `child_process.spawn`*/
|
||||
stdio?: string|Array<string|number>;
|
||||
}
|
||||
/** IO configuration for the spawned server process. For more information,
|
||||
refer to the documentation of `child_process.spawn`*/
|
||||
stdio?: string|Array<string|number>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,23 +212,23 @@ export namespace SeleniumServer {
|
||||
* @final
|
||||
*/
|
||||
export class FileDetector extends webdriver.FileDetector {
|
||||
/**
|
||||
* @constructor
|
||||
**/
|
||||
constructor();
|
||||
/**
|
||||
* @constructor
|
||||
**/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Prepares a `file` for use with the remote browser. If the provided path
|
||||
* does not reference a normal file (i.e. it does not exist or is a
|
||||
* directory), then the promise returned by this method will be resolved with
|
||||
* the original file path. Otherwise, this method will upload the file to the
|
||||
* remote server, which will return the file's path on the remote system so
|
||||
* it may be referenced in subsequent commands.
|
||||
*
|
||||
* @param {!webdriver.WebDriver} driver The driver for the current browser.
|
||||
* @param {string} file The path of the file to process.
|
||||
* @return {!webdriver.promise.Promise<string>} A promise for the processed
|
||||
* file path.
|
||||
*/
|
||||
handleFile(driver: webdriver.WebDriver, file: string): webdriver.promise.Promise<string>;
|
||||
/**
|
||||
* Prepares a `file` for use with the remote browser. If the provided path
|
||||
* does not reference a normal file (i.e. it does not exist or is a
|
||||
* directory), then the promise returned by this method will be resolved
|
||||
* with the original file path. Otherwise, this method will upload the file
|
||||
* to the remote server, which will return the file's path on the remote
|
||||
* system so it may be referenced in subsequent commands.
|
||||
*
|
||||
* @param {!webdriver.WebDriver} driver The driver for the current browser.
|
||||
* @param {string} file The path of the file to process.
|
||||
* @return {!Promise<string>} A promise for the processed
|
||||
* file path.
|
||||
*/
|
||||
handleFile(driver: webdriver.WebDriver, file: string): Promise<string>;
|
||||
}
|
||||
|
||||
Vendored
+18
-46
@@ -1,12 +1,12 @@
|
||||
import * as webdriver from './index';
|
||||
|
||||
export class Server { }
|
||||
export class Server {}
|
||||
|
||||
/**
|
||||
* @return {!Promise<string>} A promise that will resolve with the path
|
||||
* to Safari on the current system.
|
||||
*/
|
||||
export function findSafariExecutable(): any;
|
||||
export function findSafariDriver(): any;
|
||||
|
||||
/**
|
||||
* @param {string} serverUrl The URL to connect to.
|
||||
@@ -28,44 +28,18 @@ export function getRandomString(): string;
|
||||
/**
|
||||
* @implements {command.Executor}
|
||||
*/
|
||||
export class CommandExecutor {
|
||||
}
|
||||
export class CommandExecutor {}
|
||||
|
||||
/**
|
||||
* Configuration options specific to the {@link Driver SafariDriver}.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* Extracts the SafariDriver specific options from the given capabilities
|
||||
* object.
|
||||
* @param {!Capabilities} capabilities The capabilities object.
|
||||
* @return {!Options} The ChromeDriver options.
|
||||
*/
|
||||
static fromCapabilities(capabilities: webdriver.Capabilities): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to force Safari to start with a clean session. Enabling this
|
||||
* option will cause all global browser data to be deleted.
|
||||
* @param {boolean} clean Whether to make sure the session has no cookies,
|
||||
* cache entries, local storage, or databases.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setCleanSession(clean: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the logging preferences for the new session.
|
||||
* @param {!./lib/logging.Preferences} prefs The logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link Capabilities} object.
|
||||
* @param {Capabilities=} opt_capabilities The capabilities to
|
||||
* merge these options into, if any.
|
||||
* @return {!Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
|
||||
export class Options extends webdriver.Capabilities {
|
||||
/**
|
||||
* Sets the logging preferences for the new session.
|
||||
* @param {!./lib/logging.Preferences} prefs The logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,14 +52,12 @@ export class Options {
|
||||
*
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new Safari session.
|
||||
*
|
||||
* @param {(Options|Capabilities)=} opt_config The configuration
|
||||
* options for the new session.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to create
|
||||
* the driver under.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: Options | webdriver.Capabilities, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
/**
|
||||
* Creates a new Safari session.
|
||||
*
|
||||
* @param {(Options|Capabilities)=} opt_config The configuration
|
||||
* options for the new session.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: Options|webdriver.Capabilities): Driver;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@ import * as webdriver from 'selenium-webdriver';
|
||||
function TestChromeDriver() {
|
||||
let driver: chrome.Driver = chrome.Driver.createSession();
|
||||
driver = chrome.Driver.createSession(webdriver.Capabilities.chrome());
|
||||
driver = chrome.Driver.createSession(webdriver.Capabilities.chrome(),
|
||||
new remote.DriverService('executable', new chrome.Options()),
|
||||
new webdriver.promise.ControlFlow());
|
||||
|
||||
let baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
@@ -30,14 +27,10 @@ function TestChromeOptions() {
|
||||
options = options.androidPackage('com.android.chrome');
|
||||
options = options.androidProcess('com.android.chrome');
|
||||
options = options.androidUseRunningApp(true);
|
||||
options = options.setLoggingPrefs(new webdriver.logging.Preferences());
|
||||
options = options.setPerfLoggingPrefs({
|
||||
enableNetwork: true, enablePage: true, enableTimeline: true,
|
||||
tracingCategories: 'category', bufferUsageReportingInterval: 1000 });
|
||||
options = options.setProxy({ proxyType: 'proxyType' });
|
||||
options = options.setUserPreferences('preferences');
|
||||
let capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
capabilities = options.toCapabilities(webdriver.Capabilities.chrome());
|
||||
}
|
||||
|
||||
function TestServiceBuilder() {
|
||||
|
||||
@@ -3,21 +3,11 @@ import * as remote from 'selenium-webdriver/remote';
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
import * as http from 'selenium-webdriver/http';
|
||||
|
||||
function TestBinary() {
|
||||
let binary: firefox.Binary = new firefox.Binary();
|
||||
binary = new firefox.Binary('exe');
|
||||
|
||||
binary.addArguments('A', 'B', 'C');
|
||||
let promise: webdriver.promise.Promise<void> = binary.kill();
|
||||
binary.launch('profile').then((result: any) => {});
|
||||
}
|
||||
|
||||
function TestFirefoxDriver() {
|
||||
let driver: firefox.Driver = firefox.Driver.createSession();
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox());
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox(), new http.Executor(new http.HttpClient('http://someurl')));
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox(), new remote.DriverService('/dev/null', {}));
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox(), new remote.DriverService('/dev/null', {}), new webdriver.promise.ControlFlow());
|
||||
|
||||
let baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
@@ -25,41 +15,9 @@ function TestFirefoxDriver() {
|
||||
function TestFirefoxOptions() {
|
||||
let options: firefox.Options = new firefox.Options();
|
||||
|
||||
options = options.addArguments('foo', 'bar');
|
||||
options = options.windowSize({ width: 320, height: 480 });
|
||||
options = options.addExtensions('foo', 'bar');
|
||||
options = options.setPreference('a', 1);
|
||||
options = options.setPreference('a', true);
|
||||
options = options.setPreference('a', '1');
|
||||
options = options.setBinary('binary');
|
||||
options = options.setBinary(new firefox.Binary());
|
||||
options = options.setLoggingPreferences(new webdriver.logging.Preferences());
|
||||
options = options.setProfile('profile');
|
||||
options = options.setProfile(new firefox.Profile());
|
||||
options = options.setProxy({ proxyType: 'proxy' });
|
||||
let capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
}
|
||||
|
||||
function TestFirefoxProfile() {
|
||||
let profile: firefox.Profile = new firefox.Profile();
|
||||
profile = new firefox.Profile('dir');
|
||||
|
||||
let bool: boolean = profile.acceptUntrustedCerts();
|
||||
profile.addExtension('ext');
|
||||
bool = profile.assumeUntrustedCertIssuer();
|
||||
profile.encode().then((prof: string) => {});
|
||||
let num: number = profile.getPort();
|
||||
let anything: any = profile.getPreference('key');
|
||||
bool = profile.nativeEventsEnabled();
|
||||
profile.setAcceptUntrustedCerts(true);
|
||||
profile.setAssumeUntrustedCertIssuer(true);
|
||||
profile.setNativeEventsEnabled(true);
|
||||
profile.setPort(8080);
|
||||
profile.setPreference('key', 'value');
|
||||
profile.setPreference('key', 5);
|
||||
profile.setPreference('key', true);
|
||||
let stringPromise: webdriver.promise.Promise<string> = profile.writeToDisk();
|
||||
stringPromise = profile.writeToDisk(true);
|
||||
}
|
||||
|
||||
function TestServiceBuilder() {
|
||||
@@ -71,7 +29,6 @@ function TestServiceBuilder() {
|
||||
builder = builder.enableVerboseLogging();
|
||||
builder = builder.enableVerboseLogging(true);
|
||||
builder = builder.setFirefoxBinary('exe');
|
||||
builder = builder.setFirefoxBinary(new firefox.Binary());
|
||||
builder = builder.setPath('path');
|
||||
builder = builder.setStdio('config');
|
||||
builder = builder.setStdio(['A', 'B']);
|
||||
|
||||
@@ -3,9 +3,6 @@ import * as chrome from 'selenium-webdriver/chrome';
|
||||
import * as edge from 'selenium-webdriver/edge';
|
||||
import * as firefox from 'selenium-webdriver/firefox';
|
||||
import * as http from 'selenium-webdriver/http';
|
||||
import * as remote from 'selenium-webdriver/remote';
|
||||
import * as safari from 'selenium-webdriver/safari';
|
||||
import * as testing from 'selenium-webdriver/testing';
|
||||
|
||||
function TestBuilder() {
|
||||
let builder: webdriver.Builder = new webdriver.Builder();
|
||||
@@ -20,82 +17,14 @@ function TestBuilder() {
|
||||
|
||||
builder = builder.setAlertBehavior('behavior');
|
||||
builder = builder.setChromeOptions(new chrome.Options());
|
||||
builder = builder.setChromeService(new chrome.ServiceBuilder());
|
||||
builder = builder.setControlFlow(new webdriver.promise.ControlFlow());
|
||||
builder = builder.setEdgeOptions(new edge.Options());
|
||||
builder = builder.setEdgeService(new edge.ServiceBuilder());
|
||||
builder = builder.setEnableNativeEvents(true);
|
||||
builder = builder.setFirefoxOptions(new firefox.Options());
|
||||
builder = builder.setFirefoxService(new firefox.ServiceBuilder());
|
||||
builder = builder.setLoggingPrefs(new webdriver.logging.Preferences());
|
||||
builder = builder.setLoggingPrefs({ key: 'value' });
|
||||
builder = builder.setProxy({ proxyType: 'type' });
|
||||
builder = builder.setSafariOptions(new safari.Options());
|
||||
builder = builder.setScrollBehavior(1);
|
||||
builder = builder.usingServer('http://someserver');
|
||||
builder = builder.withCapabilities(new webdriver.Capabilities());
|
||||
builder = builder.withCapabilities({ something: true });
|
||||
|
||||
const chromeOptions: chrome.Options = builder.getChromeOptions();
|
||||
const firefoxOptions: firefox.Options = builder.getFirefoxOptions();
|
||||
const safariOptions: safari.Options = builder.getSafariOptions();
|
||||
}
|
||||
|
||||
declare const promise: webdriver.promise.Promise<string>;
|
||||
|
||||
function TestActionSequence() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let sequence: webdriver.ActionSequence = new webdriver.ActionSequence(driver);
|
||||
let element: webdriver.WebElement = new webdriver.WebElement(driver, 'elementId');
|
||||
element = new webdriver.WebElement(driver, promise);
|
||||
|
||||
// Click
|
||||
sequence = sequence.click();
|
||||
sequence = sequence.click(webdriver.Button.LEFT);
|
||||
sequence = sequence.click(element);
|
||||
sequence = sequence.click(element, webdriver.Button.LEFT);
|
||||
|
||||
// DoubleClick
|
||||
sequence = sequence.doubleClick();
|
||||
sequence = sequence.doubleClick(webdriver.Button.LEFT);
|
||||
sequence = sequence.doubleClick(element);
|
||||
sequence = sequence.doubleClick(element, webdriver.Button.LEFT);
|
||||
|
||||
// DragAndDrop
|
||||
sequence = sequence.dragAndDrop(element, element);
|
||||
sequence = sequence.dragAndDrop(element, { x: 1, y: 2 });
|
||||
|
||||
// KeyDown
|
||||
sequence = sequence.keyDown(webdriver.Key.ADD);
|
||||
|
||||
// KeyUp
|
||||
sequence = sequence.keyUp(webdriver.Key.ADD);
|
||||
|
||||
// MouseDown
|
||||
sequence = sequence.mouseDown();
|
||||
sequence = sequence.mouseDown(webdriver.Button.LEFT);
|
||||
sequence = sequence.mouseDown(element);
|
||||
sequence = sequence.mouseDown(element, webdriver.Button.LEFT);
|
||||
|
||||
// MouseMove
|
||||
sequence = sequence.mouseMove(element);
|
||||
sequence = sequence.mouseMove({ x: 1, y: 1 });
|
||||
sequence = sequence.mouseMove(element, { x: 1, y: 2 });
|
||||
|
||||
// MouseUp
|
||||
sequence = sequence.mouseUp();
|
||||
sequence = sequence.mouseUp(webdriver.Button.LEFT);
|
||||
sequence = sequence.mouseUp(element);
|
||||
sequence = sequence.mouseUp(element, webdriver.Button.LEFT);
|
||||
|
||||
// SendKeys
|
||||
sequence = sequence.sendKeys('A', 'B', 'C');
|
||||
sequence = sequence.sendKeys('A', webdriver.Key.NULL);
|
||||
|
||||
sequence.perform().then(() => {});
|
||||
}
|
||||
|
||||
function TestTouchSequence() {
|
||||
@@ -148,14 +77,6 @@ function TestBrowser() {
|
||||
browser = webdriver.Browser.SAFARI;
|
||||
}
|
||||
|
||||
function TestButton() {
|
||||
let button: string;
|
||||
|
||||
button = webdriver.Button.LEFT;
|
||||
button = webdriver.Button.MIDDLE;
|
||||
button = webdriver.Button.RIGHT;
|
||||
}
|
||||
|
||||
function TestCapabilities() {
|
||||
let capabilities: webdriver.Capabilities = new webdriver.Capabilities();
|
||||
capabilities = new webdriver.Capabilities(webdriver.Capabilities.chrome());
|
||||
@@ -213,119 +134,6 @@ function TestCapability() {
|
||||
capability = webdriver.Capability.VERSION;
|
||||
}
|
||||
|
||||
function TestCommand() {
|
||||
let command: webdriver.Command = new webdriver.Command(webdriver.CommandName.ADD_COOKIE);
|
||||
|
||||
let name: string = command.getName();
|
||||
let param: any = command.getParameter('param');
|
||||
|
||||
let params: any = command.getParameters();
|
||||
|
||||
command = command.setParameter('param', 123);
|
||||
command = command.setParameters({ param: 123 });
|
||||
}
|
||||
|
||||
function TestCommandName() {
|
||||
let command: string;
|
||||
|
||||
command = webdriver.CommandName.ACCEPT_ALERT;
|
||||
command = webdriver.CommandName.ADD_COOKIE;
|
||||
command = webdriver.CommandName.CLEAR_APP_CACHE;
|
||||
command = webdriver.CommandName.CLEAR_ELEMENT;
|
||||
command = webdriver.CommandName.CLEAR_LOCAL_STORAGE;
|
||||
command = webdriver.CommandName.CLEAR_SESSION_STORAGE;
|
||||
command = webdriver.CommandName.CLICK;
|
||||
command = webdriver.CommandName.CLICK_ELEMENT;
|
||||
command = webdriver.CommandName.CLOSE;
|
||||
command = webdriver.CommandName.DELETE_ALL_COOKIES;
|
||||
command = webdriver.CommandName.DELETE_COOKIE;
|
||||
command = webdriver.CommandName.DESCRIBE_SESSION;
|
||||
command = webdriver.CommandName.DISMISS_ALERT;
|
||||
command = webdriver.CommandName.DOUBLE_CLICK;
|
||||
command = webdriver.CommandName.ELEMENT_EQUALS;
|
||||
command = webdriver.CommandName.EXECUTE_ASYNC_SCRIPT;
|
||||
command = webdriver.CommandName.EXECUTE_SCRIPT;
|
||||
command = webdriver.CommandName.EXECUTE_SQL;
|
||||
command = webdriver.CommandName.FIND_CHILD_ELEMENT;
|
||||
command = webdriver.CommandName.FIND_CHILD_ELEMENTS;
|
||||
command = webdriver.CommandName.FIND_ELEMENT;
|
||||
command = webdriver.CommandName.FIND_ELEMENTS;
|
||||
command = webdriver.CommandName.GET;
|
||||
command = webdriver.CommandName.GET_ACTIVE_ELEMENT;
|
||||
command = webdriver.CommandName.GET_ALERT_TEXT;
|
||||
command = webdriver.CommandName.GET_ALL_COOKIES;
|
||||
command = webdriver.CommandName.GET_APP_CACHE;
|
||||
command = webdriver.CommandName.GET_APP_CACHE_STATUS;
|
||||
command = webdriver.CommandName.GET_AVAILABLE_LOG_TYPES;
|
||||
command = webdriver.CommandName.GET_COOKIE;
|
||||
command = webdriver.CommandName.GET_CURRENT_URL;
|
||||
command = webdriver.CommandName.GET_CURRENT_WINDOW_HANDLE;
|
||||
command = webdriver.CommandName.GET_ELEMENT_ATTRIBUTE;
|
||||
command = webdriver.CommandName.GET_ELEMENT_LOCATION;
|
||||
command = webdriver.CommandName.GET_ELEMENT_LOCATION_IN_VIEW;
|
||||
command = webdriver.CommandName.GET_ELEMENT_SIZE;
|
||||
command = webdriver.CommandName.GET_ELEMENT_TAG_NAME;
|
||||
command = webdriver.CommandName.GET_ELEMENT_TEXT;
|
||||
command = webdriver.CommandName.GET_ELEMENT_VALUE_OF_CSS_PROPERTY;
|
||||
command = webdriver.CommandName.GET_LOCAL_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.GET_LOCAL_STORAGE_KEYS;
|
||||
command = webdriver.CommandName.GET_LOCAL_STORAGE_SIZE;
|
||||
command = webdriver.CommandName.GET_LOCATION;
|
||||
command = webdriver.CommandName.GET_LOG;
|
||||
command = webdriver.CommandName.GET_PAGE_SOURCE;
|
||||
command = webdriver.CommandName.GET_SCREEN_ORIENTATION;
|
||||
command = webdriver.CommandName.GET_SERVER_STATUS;
|
||||
command = webdriver.CommandName.GET_SESSION_LOGS;
|
||||
command = webdriver.CommandName.GET_SESSION_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.GET_SESSION_STORAGE_KEYS;
|
||||
command = webdriver.CommandName.GET_SESSION_STORAGE_SIZE;
|
||||
command = webdriver.CommandName.GET_SESSIONS;
|
||||
command = webdriver.CommandName.GET_TITLE;
|
||||
command = webdriver.CommandName.GET_WINDOW_HANDLES;
|
||||
command = webdriver.CommandName.GET_WINDOW_POSITION;
|
||||
command = webdriver.CommandName.GET_WINDOW_SIZE;
|
||||
command = webdriver.CommandName.GO_BACK;
|
||||
command = webdriver.CommandName.GO_FORWARD;
|
||||
command = webdriver.CommandName.IMPLICITLY_WAIT;
|
||||
command = webdriver.CommandName.IS_BROWSER_ONLINE;
|
||||
command = webdriver.CommandName.IS_ELEMENT_DISPLAYED;
|
||||
command = webdriver.CommandName.IS_ELEMENT_ENABLED;
|
||||
command = webdriver.CommandName.IS_ELEMENT_SELECTED;
|
||||
command = webdriver.CommandName.MAXIMIZE_WINDOW;
|
||||
command = webdriver.CommandName.MOUSE_DOWN;
|
||||
command = webdriver.CommandName.MOUSE_UP;
|
||||
command = webdriver.CommandName.MOVE_TO;
|
||||
command = webdriver.CommandName.NEW_SESSION;
|
||||
command = webdriver.CommandName.QUIT;
|
||||
command = webdriver.CommandName.REFRESH;
|
||||
command = webdriver.CommandName.REMOVE_LOCAL_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.REMOVE_SESSION_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.SCREENSHOT;
|
||||
command = webdriver.CommandName.SEND_KEYS_TO_ACTIVE_ELEMENT;
|
||||
command = webdriver.CommandName.SEND_KEYS_TO_ELEMENT;
|
||||
command = webdriver.CommandName.SET_ALERT_TEXT;
|
||||
command = webdriver.CommandName.SET_BROWSER_ONLINE;
|
||||
command = webdriver.CommandName.SET_LOCAL_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.SET_LOCATION;
|
||||
command = webdriver.CommandName.SET_SCREEN_ORIENTATION;
|
||||
command = webdriver.CommandName.SET_SCRIPT_TIMEOUT;
|
||||
command = webdriver.CommandName.SET_SESSION_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.SET_TIMEOUT;
|
||||
command = webdriver.CommandName.SET_WINDOW_POSITION;
|
||||
command = webdriver.CommandName.SET_WINDOW_SIZE;
|
||||
command = webdriver.CommandName.SUBMIT_ELEMENT;
|
||||
command = webdriver.CommandName.SWITCH_TO_FRAME;
|
||||
command = webdriver.CommandName.SWITCH_TO_WINDOW;
|
||||
command = webdriver.CommandName.TOUCH_DOUBLE_TAP;
|
||||
command = webdriver.CommandName.TOUCH_DOWN;
|
||||
command = webdriver.CommandName.TOUCH_FLICK;
|
||||
command = webdriver.CommandName.TOUCH_LONG_PRESS;
|
||||
command = webdriver.CommandName.TOUCH_MOVE;
|
||||
command = webdriver.CommandName.TOUCH_SCROLL;
|
||||
command = webdriver.CommandName.TOUCH_SINGLE_TAP;
|
||||
command = webdriver.CommandName.TOUCH_UP;
|
||||
}
|
||||
|
||||
function TestEventEmitter() {
|
||||
let emitter: webdriver.EventEmitter = new webdriver.EventEmitter();
|
||||
|
||||
@@ -510,7 +318,7 @@ function TestWebDriverOptions() {
|
||||
build();
|
||||
|
||||
let options: webdriver.Options = new webdriver.Options(driver);
|
||||
let promise: webdriver.promise.Promise<void>;
|
||||
let promise: Promise<void>;
|
||||
|
||||
let name: string = 'name';
|
||||
let value: string = 'value';
|
||||
@@ -536,7 +344,6 @@ function TestWebDriverOptions() {
|
||||
options.getCookies().then((cookies: webdriver.IWebDriverCookie[]) => { });
|
||||
|
||||
let logs: webdriver.Logs = options.logs();
|
||||
let timeouts: webdriver.Timeouts = options.timeouts();
|
||||
let window: webdriver.Window = options.window();
|
||||
}
|
||||
|
||||
@@ -546,7 +353,7 @@ function TestWebDriverTargetLocator() {
|
||||
build();
|
||||
|
||||
let locator: webdriver.TargetLocator = new webdriver.TargetLocator(driver);
|
||||
let promise: webdriver.promise.Promise<void>;
|
||||
let promise: Promise<void>;
|
||||
|
||||
let element: webdriver.WebElement = locator.activeElement();
|
||||
let alert: webdriver.Alert = locator.alert();
|
||||
@@ -555,28 +362,15 @@ function TestWebDriverTargetLocator() {
|
||||
promise = locator.window('nameOrHandle');
|
||||
}
|
||||
|
||||
function TestWebDriverTimeouts() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let timeouts: webdriver.Timeouts = new webdriver.Timeouts(driver);
|
||||
let promise: webdriver.promise.Promise<void>;
|
||||
|
||||
promise = timeouts.implicitlyWait(123);
|
||||
promise = timeouts.pageLoadTimeout(123);
|
||||
promise = timeouts.setScriptTimeout(123);
|
||||
}
|
||||
|
||||
function TestWebDriverWindow() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let window: webdriver.Window = new webdriver.Window(driver);
|
||||
let locationPromise: webdriver.promise.Promise<webdriver.ILocation>;
|
||||
let sizePromise: webdriver.promise.Promise<webdriver.ISize>;
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
let locationPromise: Promise<webdriver.ILocation>;
|
||||
let sizePromise: Promise<webdriver.ISize>;
|
||||
let voidPromise: Promise<void>;
|
||||
|
||||
locationPromise = window.getPosition();
|
||||
sizePromise = window.getSize();
|
||||
@@ -585,8 +379,8 @@ function TestWebDriverWindow() {
|
||||
voidPromise = window.setSize(12, 34);
|
||||
}
|
||||
|
||||
declare const sessionPromise: webdriver.promise.Promise<webdriver.Session>;
|
||||
declare let booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
declare const sessionPromise: Promise<webdriver.Session>;
|
||||
declare let booleanPromise: Promise<boolean>;
|
||||
declare const booleanCondition: webdriver.Condition<boolean>;
|
||||
declare const webElementCondition: webdriver.WebElementCondition;
|
||||
|
||||
@@ -594,27 +388,14 @@ function TestWebDriver() {
|
||||
let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
|
||||
let httpClient: http.HttpClient = new http.HttpClient('http://someserver');
|
||||
let executor: http.Executor = new http.Executor(httpClient);
|
||||
let flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow();
|
||||
let driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor);
|
||||
driver = new webdriver.WebDriver(session, executor, flow);
|
||||
driver = new webdriver.WebDriver(sessionPromise, executor);
|
||||
driver = new webdriver.WebDriver(sessionPromise, executor, flow);
|
||||
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
let stringPromise: webdriver.promise.Promise<string>;
|
||||
let voidPromise: Promise<void>;
|
||||
let stringPromise: Promise<string>;
|
||||
let webElementPromise: webdriver.WebElementPromise;
|
||||
|
||||
let actions: webdriver.ActionSequence = driver.actions();
|
||||
let touchActions: webdriver.TouchSequence = driver.touchActions();
|
||||
|
||||
// call
|
||||
stringPromise = driver.call<string>(() => 'value');
|
||||
stringPromise = driver.call<string>(() => stringPromise);
|
||||
stringPromise = driver.call<string>(() => 'value', driver);
|
||||
stringPromise = driver.call<string>((a: number) => 'value', driver, 1);
|
||||
|
||||
voidPromise = driver.close();
|
||||
flow = driver.controlFlow();
|
||||
|
||||
// executeAsyncScript
|
||||
stringPromise = driver.executeAsyncScript<string>('function(){}');
|
||||
@@ -654,7 +435,6 @@ function TestWebDriver() {
|
||||
driver.setFileDetector(fileDetector);
|
||||
|
||||
voidPromise = driver.quit();
|
||||
voidPromise = driver.schedule<void>(new webdriver.Command(webdriver.CommandName.CLICK), 'ABC');
|
||||
voidPromise = driver.sleep(123);
|
||||
stringPromise = driver.takeScreenshot();
|
||||
|
||||
@@ -662,20 +442,19 @@ function TestWebDriver() {
|
||||
booleanPromise = driver.wait(booleanCondition);
|
||||
booleanPromise = driver.wait((driver: webdriver.WebDriver) => true);
|
||||
booleanPromise = driver.wait((driver: webdriver.WebDriver) => Promise.resolve(true));
|
||||
booleanPromise = driver.wait((driver: webdriver.WebDriver) => webdriver.promise.Promise.resolve(true));
|
||||
booleanPromise = driver.wait((driver: webdriver.WebDriver) => Promise.resolve(true));
|
||||
booleanPromise = driver.wait(booleanPromise, 123);
|
||||
booleanPromise = driver.wait(booleanPromise, 123, 'Message');
|
||||
webElementPromise = driver.wait(webElementCondition);
|
||||
voidPromise = driver.wait(webElementCondition).click();
|
||||
|
||||
driver = webdriver.WebDriver.attachToSession(executor, 'ABC');
|
||||
driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android());
|
||||
}
|
||||
|
||||
declare const serializable: webdriver.Serializable<string>;
|
||||
|
||||
function TestSerializable() {
|
||||
let serial: string | webdriver.promise.IThenable<string> = serializable.serialize();
|
||||
let serial: string | Promise<string> = serializable.serialize();
|
||||
}
|
||||
|
||||
function TestWebElement() {
|
||||
@@ -686,11 +465,10 @@ function TestWebElement() {
|
||||
let element: webdriver.WebElement;
|
||||
|
||||
element = new webdriver.WebElement(driver, 'elementId');
|
||||
element = new webdriver.WebElement(driver, promise);
|
||||
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
let stringPromise: webdriver.promise.Promise<string>;
|
||||
let booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
let voidPromise: Promise<void>;
|
||||
let stringPromise: Promise<string>;
|
||||
let booleanPromise: Promise<boolean>;
|
||||
|
||||
voidPromise = element.clear();
|
||||
voidPromise = element.click();
|
||||
@@ -783,89 +561,7 @@ function TestLoggingEntry() {
|
||||
let type: string = entry.type;
|
||||
}
|
||||
|
||||
declare let stringPromise: webdriver.promise.Promise<string>;
|
||||
|
||||
function TestPromiseModule() {
|
||||
let cancellationError: webdriver.promise.CancellationError = new webdriver.promise.CancellationError();
|
||||
cancellationError = new webdriver.promise.CancellationError('message');
|
||||
let str: string = cancellationError.message;
|
||||
str = cancellationError.name;
|
||||
|
||||
let numberPromise: webdriver.promise.Promise<number>;
|
||||
let booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
|
||||
webdriver.promise.all([stringPromise]).then((values: string[]) => {});
|
||||
|
||||
webdriver.promise.asap('abc', (value: any) => true);
|
||||
webdriver.promise.asap('abc', (value: any) => {}, (err: any) => 'ABC');
|
||||
|
||||
stringPromise = webdriver.promise.checkedNodeCall<string>((err: any, value: any) => 'abc');
|
||||
|
||||
webdriver.promise.consume(() => {
|
||||
return 5;
|
||||
}).then((value: number) => {});
|
||||
webdriver.promise.consume(() => {
|
||||
return 5;
|
||||
}, this).then((value: number) => {});
|
||||
webdriver.promise.consume((a: number, b: number, c: number) => 5, this, 1, 2, 3)
|
||||
.then((value: number) => {});
|
||||
|
||||
let numbersPromise: webdriver.promise.Promise<number[]> = webdriver.promise.filter([1, 2, 3], (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.filter([1, 2, 3], (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = webdriver.promise.filter(numbersPromise, (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.filter(numbersPromise, (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
numbersPromise = webdriver.promise.map([1, 2, 3], (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.map([1, 2, 3], (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = webdriver.promise.map(numbersPromise, (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.map(numbersPromise, (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
let flow: webdriver.promise.ControlFlow = webdriver.promise.controlFlow();
|
||||
|
||||
stringPromise = webdriver.promise.createFlow<string>((newFlow: webdriver.promise.ControlFlow) => 'ABC');
|
||||
|
||||
let deferred: webdriver.promise.Deferred<string>;
|
||||
deferred = webdriver.promise.defer<string>();
|
||||
deferred = webdriver.promise.defer<string>();
|
||||
|
||||
stringPromise = deferred.promise;
|
||||
|
||||
deferred.fulfill('ABC');
|
||||
deferred.reject('error');
|
||||
|
||||
voidPromise = webdriver.promise.delayed(123);
|
||||
|
||||
voidPromise = webdriver.promise.fulfilled<void>();
|
||||
stringPromise = webdriver.promise.fulfilled('abc');
|
||||
|
||||
stringPromise = webdriver.promise.fullyResolved<string>('abc');
|
||||
|
||||
let bool: boolean = webdriver.promise.isGenerator(() => {});
|
||||
let isPromise: boolean = webdriver.promise.isPromise('ABC');
|
||||
|
||||
stringPromise = webdriver.promise.rejected<string>('{a: 123}');
|
||||
|
||||
webdriver.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
|
||||
|
||||
numberPromise = webdriver.promise.when('abc', (value: any) => 123, (err: Error) => 123);
|
||||
}
|
||||
declare let stringPromise: Promise<string>;
|
||||
|
||||
function TestUntilModule() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
@@ -900,92 +596,3 @@ function TestUntilModule() {
|
||||
conditionWebElement = webdriver.until.elementTextMatches(el, /text/);
|
||||
conditionWebElements = webdriver.until.elementsLocated(webdriver.By.className('class'));
|
||||
}
|
||||
|
||||
function TestControlFlow() {
|
||||
let flow: webdriver.promise.ControlFlow;
|
||||
flow = new webdriver.promise.ControlFlow();
|
||||
|
||||
let emitter: webdriver.EventEmitter = flow;
|
||||
|
||||
let eventType: string;
|
||||
|
||||
eventType = webdriver.promise.ControlFlow.EventType.IDLE;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.RESET;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.SCHEDULE_TASK;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION;
|
||||
|
||||
let stringPromise: webdriver.promise.Promise<string>;
|
||||
stringPromise = flow.execute(() => 'value');
|
||||
stringPromise = flow.execute(() => stringPromise);
|
||||
stringPromise = flow.execute(() => stringPromise, 'Description');
|
||||
|
||||
let schedule: string;
|
||||
schedule = flow.toString();
|
||||
schedule = flow.getSchedule();
|
||||
schedule = flow.getSchedule(true);
|
||||
|
||||
flow.reset();
|
||||
|
||||
let voidPromise: webdriver.promise.Promise<void> = flow.timeout(123);
|
||||
voidPromise = flow.timeout(123, 'Description');
|
||||
|
||||
stringPromise = flow.wait(stringPromise);
|
||||
|
||||
voidPromise = flow.wait<void>(() => true);
|
||||
voidPromise = flow.wait<void>(() => true, 123);
|
||||
voidPromise = flow.wait<void>(() => stringPromise, 123, 'Timeout Message');
|
||||
}
|
||||
|
||||
function TestDeferred() {
|
||||
let deferred: webdriver.promise.Deferred<string>;
|
||||
|
||||
deferred = new webdriver.promise.Deferred<string>();
|
||||
deferred = new webdriver.promise.Deferred<string>(new webdriver.promise.ControlFlow());
|
||||
|
||||
let promise: webdriver.promise.Promise<string> = deferred.promise;
|
||||
|
||||
deferred.errback(new Error('Error'));
|
||||
deferred.errback('Error');
|
||||
deferred.fulfill('abc');
|
||||
deferred.reject(new Error('Error'));
|
||||
deferred.reject('Error');
|
||||
deferred.removeAll();
|
||||
}
|
||||
|
||||
declare const controlFlow: webdriver.promise.ControlFlow;
|
||||
|
||||
function TestPromiseClass() {
|
||||
let promise: webdriver.promise.Promise<string>;
|
||||
promise = new webdriver.promise.Promise<string>((resolve, reject) => {
|
||||
resolve("");
|
||||
resolve(Promise.resolve(""));
|
||||
reject(new Error());
|
||||
}, controlFlow);
|
||||
|
||||
promise = promise.then<string>();
|
||||
promise = promise.then((a: string) => 'cde');
|
||||
// tslint:disable-next-line void-return (need `--strictNullChecks` to change `void` to `undefined`)
|
||||
const promiseOrVoid: webdriver.promise.Promise<string | void> = promise.then((a: string) => 'cde', (e: any) => {});
|
||||
const promiseOrNumber: webdriver.promise.Promise<string | number> = promise.then((a: string) => 'cde', (e: any) => 123);
|
||||
}
|
||||
|
||||
function TestThenableClass() {
|
||||
// TODO: this doesn't test the Thenable class, it uses a Promise!
|
||||
let thenable: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>((resolve, reject) => {
|
||||
resolve('a');
|
||||
});
|
||||
|
||||
thenable = thenable.then((a: string) => 'cde');
|
||||
// tslint:disable-next-line void-return (need `--strictNullChecks` to change `void` to `undefined`)
|
||||
const thenableOrVoid: webdriver.promise.Promise<string | void> = thenable.then((a: string) => 'cde', (e: any) => {});
|
||||
const thenableOrNumber: webdriver.promise.Promise<string | number> = thenable.then((a: string) => 'cde', (e: any) => 123);
|
||||
}
|
||||
|
||||
async function TestAsyncAwaitable() {
|
||||
let thenable: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>((resolve, reject) => resolve('foo'));
|
||||
let str: string = await thenable;
|
||||
}
|
||||
|
||||
function TestPromiseManagerFlag() {
|
||||
webdriver.promise.USE_PROMISE_MANAGER = false;
|
||||
}
|
||||
|
||||
@@ -24,14 +24,11 @@
|
||||
"firefox.d.ts",
|
||||
"http.d.ts",
|
||||
"ie.d.ts",
|
||||
"opera.d.ts",
|
||||
"remote.d.ts",
|
||||
"safari.d.ts",
|
||||
"testing.d.ts",
|
||||
"test/index.ts",
|
||||
"test/chrome.ts",
|
||||
"test/firefox.ts",
|
||||
"test/remote.ts",
|
||||
"test/testing.ts"
|
||||
"test/remote.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+362
@@ -0,0 +1,362 @@
|
||||
import * as webdriver from './index';
|
||||
import * as remote from './remote';
|
||||
import * as http from './http';
|
||||
|
||||
/**
|
||||
* Creates a new WebDriver client for Chrome.
|
||||
*
|
||||
* @extends {webdriver.WebDriver}
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new session with the ChromeDriver.
|
||||
*
|
||||
* @param {(Capabilities|Options)=} opt_config The configuration options.
|
||||
* @param {(remote.DriverService|http.Executor)=} opt_serviceExecutor Either
|
||||
* a DriverService to use for the remote end, or a preconfigured executor
|
||||
* for an externally managed endpoint. If neither is provided, the
|
||||
* {@linkplain ##getDefaultService default service} will be used by
|
||||
* default.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to use, or `null`
|
||||
* to use the currently active flow.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: Options | webdriver.CreateSessionCapabilities, opt_service?: remote.DriverService | http.Executor, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
}
|
||||
|
||||
export interface IOptionsValues {
|
||||
args: string[];
|
||||
binary?: string;
|
||||
detach: boolean;
|
||||
extensions: string[];
|
||||
localState?: any;
|
||||
logFile?: string;
|
||||
prefs?: any;
|
||||
}
|
||||
|
||||
export interface IPerfLoggingPrefs {
|
||||
enableNetwork: boolean;
|
||||
enablePage: boolean;
|
||||
enableTimeline: boolean;
|
||||
tracingCategories: string;
|
||||
bufferUsageReportingInterval: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for managing ChromeDriver specific options.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Extracts the ChromeDriver specific options from the given capabilities
|
||||
* object.
|
||||
* @param {!webdriver.Capabilities} capabilities The capabilities object.
|
||||
* @return {!Options} The ChromeDriver options.
|
||||
*/
|
||||
static fromCapabilities(capabilities: webdriver.Capabilities): Options;
|
||||
|
||||
/**
|
||||
* Add additional command line arguments to use when launching the Chrome
|
||||
* browser. Each argument may be specified with or without the '--' prefix
|
||||
* (e.g. '--foo' and 'foo'). Arguments with an associated value should be
|
||||
* delimited by an '=': 'foo=bar'.
|
||||
* @param {...(string|!Array.<string>)} var_args The arguments to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...var_args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Configures the chromedriver to start Chrome in headless mode.
|
||||
*
|
||||
* > __NOTE:__ Resizing the browser window in headless mode is only supported
|
||||
* > in Chrome 60. Users are encouraged to set an initial window size with
|
||||
* > the {@link #windowSize windowSize({width, height})} option.
|
||||
*
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
headless(): Options;
|
||||
|
||||
/**
|
||||
* List of Chrome command line switches to exclude that ChromeDriver by default
|
||||
* passes when starting Chrome. Do not prefix switches with '--'.
|
||||
*
|
||||
* @param {...(string|!Array<string>)} var_args The switches to exclude.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
excludeSwitches(...var_args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Add additional extensions to install when launching Chrome. Each extension
|
||||
* should be specified as the path to the packed CRX file, or a Buffer for an
|
||||
* extension.
|
||||
* @param {...(string|!Buffer|!Array.<(string|!Buffer)>)} var_args The
|
||||
* extensions to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addExtensions(...var_args: any[]): Options;
|
||||
|
||||
/**
|
||||
* Sets the path to the Chrome binary to use. On Mac OS X, this path should
|
||||
* reference the actual Chrome executable, not just the application binary
|
||||
* (e.g. '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome').
|
||||
*
|
||||
* The binary path be absolute or relative to the chromedriver server
|
||||
* executable, but it must exist on the machine that will launch Chrome.
|
||||
*
|
||||
* @param {string} path The path to the Chrome binary to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeBinaryPath(path: string): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to leave the started Chrome browser running if the controlling
|
||||
* ChromeDriver service is killed before {@link webdriver.WebDriver#quit()} is
|
||||
* called.
|
||||
* @param {boolean} detach Whether to leave the browser running if the
|
||||
* chromedriver service is killed before the session.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
detachDriver(detach: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the user preferences for Chrome's user profile. See the 'Preferences'
|
||||
* file in Chrome's user data directory for examples.
|
||||
* @param {!Object} prefs Dictionary of user preferences to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setUserPreferences(prefs: any): Options;
|
||||
|
||||
/**
|
||||
* Sets the logging preferences for the new session.
|
||||
* @param {!webdriver.logging.Preferences} prefs The logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
|
||||
|
||||
/**
|
||||
* Sets the performance logging preferences. Options include:
|
||||
*
|
||||
* - `enableNetwork`: Whether or not to collect events from Network domain.
|
||||
* - `enablePage`: Whether or not to collect events from Page domain.
|
||||
* - `enableTimeline`: Whether or not to collect events from Timeline domain.
|
||||
* Note: when tracing is enabled, Timeline domain is implicitly disabled,
|
||||
* unless `enableTimeline` is explicitly set to true.
|
||||
* - `tracingCategories`: A comma-separated string of Chrome tracing categories
|
||||
* for which trace events should be collected. An unspecified or empty
|
||||
* string disables tracing.
|
||||
* - `bufferUsageReportingInterval`: The requested number of milliseconds
|
||||
* between DevTools trace buffer usage events. For example, if 1000, then
|
||||
* once per second, DevTools will report how full the trace buffer is. If a
|
||||
* report indicates the buffer usage is 100%, a warning will be issued.
|
||||
*
|
||||
* @param {{enableNetwork: boolean,
|
||||
* enablePage: boolean,
|
||||
* enableTimeline: boolean,
|
||||
* tracingCategories: string,
|
||||
* bufferUsageReportingInterval: number}} prefs The performance
|
||||
* logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setPerfLoggingPrefs(prefs: IPerfLoggingPrefs): Options;
|
||||
|
||||
/**
|
||||
* Sets preferences for the 'Local State' file in Chrome's user data
|
||||
* directory.
|
||||
* @param {!Object} state Dictionary of local state preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLocalState(state: any): Options;
|
||||
|
||||
/**
|
||||
* Sets the name of the activity hosting a Chrome-based Android WebView. This
|
||||
* option must be set to connect to an [Android WebView](
|
||||
* https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android)
|
||||
*
|
||||
* @param {string} name The activity name.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidActivity(name: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the device serial number to connect to via ADB. If not specified, the
|
||||
* ChromeDriver will select an unused device at random. An error will be
|
||||
* returned if all devices already have active sessions.
|
||||
*
|
||||
* @param {string} serial The device serial number to connect to.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidDeviceSerial(serial: string): Options;
|
||||
|
||||
/**
|
||||
* Configures the ChromeDriver to launch Chrome on Android via adb. This
|
||||
* function is shorthand for
|
||||
* {@link #androidPackage options.androidPackage('com.android.chrome')}.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidChrome(): Options;
|
||||
|
||||
/**
|
||||
* Sets the package name of the Chrome or WebView app.
|
||||
*
|
||||
* @param {?string} pkg The package to connect to, or `null` to disable Android
|
||||
* and switch back to using desktop Chrome.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidPackage(pkg: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the process name of the Activity hosting the WebView (as given by `ps`).
|
||||
* If not specified, the process name is assumed to be the same as
|
||||
* {@link #androidPackage}.
|
||||
*
|
||||
* @param {string} processName The main activity name.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidProcess(processName: string): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to connect to an already-running instead of the specified
|
||||
* {@linkplain #androidProcess app} instead of launching the app with a clean
|
||||
* data directory.
|
||||
*
|
||||
* @param {boolean} useRunning Whether to connect to a running instance.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
androidUseRunningApp(useRunning: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the path to Chrome's log file. This path should exist on the machine
|
||||
* that will launch Chrome.
|
||||
* @param {string} path Path to the log file to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeLogFile(path: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the directory to store Chrome minidumps in. This option is only
|
||||
* supported when ChromeDriver is running on Linux.
|
||||
* @param {string} path The directory path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setChromeMinidumpPath(path: string): Options;
|
||||
|
||||
/**
|
||||
* Configures Chrome to emulate a mobile device. For more information, refer
|
||||
* to the ChromeDriver project page on [mobile emulation][em]. Configuration
|
||||
* options include:
|
||||
*
|
||||
* - `deviceName`: The name of a pre-configured [emulated device][devem]
|
||||
* - `width`: screen width, in pixels
|
||||
* - `height`: screen height, in pixels
|
||||
* - `pixelRatio`: screen pixel ratio
|
||||
*
|
||||
* __Example 1: Using a Pre-configured Device__
|
||||
*
|
||||
* let options = new chrome.Options().setMobileEmulation(
|
||||
* {deviceName: 'Google Nexus 5'});
|
||||
*
|
||||
* let driver = new chrome.Driver(options);
|
||||
*
|
||||
* __Example 2: Using Custom Screen Configuration__
|
||||
*
|
||||
* let options = new chrome.Options().setMobileEmulation({
|
||||
* width: 360,
|
||||
* height: 640,
|
||||
* pixelRatio: 3.0
|
||||
* });
|
||||
*
|
||||
* let driver = new chrome.Driver(options);
|
||||
*
|
||||
*
|
||||
* [em]: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation
|
||||
* [devem]: https://developer.chrome.com/devtools/docs/device-mode
|
||||
*
|
||||
* @param {?({deviceName: string}|
|
||||
* {width: number, height: number, pixelRatio: number})} config The
|
||||
* mobile emulation configuration, or `null` to disable emulation.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setMobileEmulation(config: any): Options;
|
||||
|
||||
/**
|
||||
* Sets the proxy settings for the new session.
|
||||
* @param {webdriver.ProxyConfig} proxy The proxy configuration to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProxy(proxy: webdriver.ProxyConfig): Options;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link webdriver.Capabilities} object.
|
||||
* @param {webdriver.Capabilities=} opt_capabilities The capabilities to merge
|
||||
* these options into, if any.
|
||||
* @return {!webdriver.Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link remote.DriverService} instances that manage a ChromeDriver
|
||||
* server.
|
||||
*/
|
||||
export class ServiceBuilder extends remote.DriverService.Builder {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the chromedriver on the current
|
||||
* PATH.
|
||||
* @throws {Error} If provided executable does not exist, or the chromedriver
|
||||
* cannot be found on the PATH.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
|
||||
/**
|
||||
* Sets which port adb is listening to. _The ChromeDriver will connect to adb
|
||||
* if an {@linkplain Options#androidPackage Android session} is requested, but
|
||||
* adb **must** be started beforehand._
|
||||
*
|
||||
* @param {number} port Which port adb is running on.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
setAdbPort(port: number): this;
|
||||
|
||||
/**
|
||||
* Sets the path of the log file the driver should log to. If a log file is
|
||||
* not specified, the driver will log to stderr.
|
||||
* @param {string} path Path of the log file to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
loggingTo(path: string): this;
|
||||
|
||||
/**
|
||||
* Enables verbose logging.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
enableVerboseLogging(): this;
|
||||
|
||||
/**
|
||||
* Sets the number of threads the driver should use to manage HTTP requests.
|
||||
* By default, the driver will use 4 threads.
|
||||
* @param {number} n The number of threads to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
setNumHttpThreads(n: number): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default ChromeDriver service. If such a service has not been
|
||||
* configured, one will be constructed using the default configuration for
|
||||
* a ChromeDriver executable found on the system PATH.
|
||||
* @return {!remote.DriverService} The default ChromeDriver service.
|
||||
*/
|
||||
export function getDefaultService(): remote.DriverService;
|
||||
|
||||
/**
|
||||
* Sets the default service to use for new ChromeDriver instances.
|
||||
* @param {!remote.DriverService} service The service to use.
|
||||
* @throws {Error} If the default service is currently running.
|
||||
*/
|
||||
export function setDefaultService(service: remote.DriverService): void;
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
import * as webdriver from './index';
|
||||
import * as remote from './remote';
|
||||
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new browser session for Microsoft's Edge browser.
|
||||
*
|
||||
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
|
||||
* options.
|
||||
* @param {remote.DriverService=} opt_service The session to use; will use
|
||||
* the {@linkplain #getDefaultService default service} by default.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to use, or
|
||||
* {@code null} to use the currently active flow.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: webdriver.CreateSessionCapabilities, opt_service?: remote.DriverService, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for managing MicrosoftEdgeDriver specific options.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* Extracts the MicrosoftEdgeDriver specific options from the given
|
||||
* capabilities object.
|
||||
* @param {!capabilities.Capabilities} caps The capabilities object.
|
||||
* @return {!Options} The MicrosoftEdgeDriver options.
|
||||
*/
|
||||
static fromCapabilities(cap: webdriver.Capabilities): Options;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link capabilities.Capabilities}
|
||||
* object.
|
||||
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
|
||||
* merge these options into, if any.
|
||||
* @return {!capabilities.Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link remote.DriverService} instances that manage a
|
||||
* MicrosoftEdgeDriver server in a child process.
|
||||
*/
|
||||
export class ServiceBuilder extends remote.DriverService.Builder {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the MicrosoftEdgeDriver on the current
|
||||
* PATH.
|
||||
* @throws {Error} If provided executable does not exist, or the
|
||||
* MicrosoftEdgeDriver cannot be found on the PATH.
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default MicrosoftEdgeDriver service. If such a service has
|
||||
* not been configured, one will be constructed using the default configuration
|
||||
* for an MicrosoftEdgeDriver executable found on the system PATH.
|
||||
* @return {!remote.DriverService} The default MicrosoftEdgeDriver service.
|
||||
*/
|
||||
export function getDefaultService(): remote.DriverService;
|
||||
|
||||
/**
|
||||
* Sets the default service to use for new MicrosoftEdgeDriver instances.
|
||||
* @param {!remote.DriverService} service The service to use.
|
||||
* @throws {Error} If the default service is currently running.
|
||||
*/
|
||||
export function setDefaultService(service: remote.DriverService): void;
|
||||
+335
@@ -0,0 +1,335 @@
|
||||
import * as webdriver from './index';
|
||||
import * as remote from './remote';
|
||||
import * as http from './http';
|
||||
|
||||
/**
|
||||
* Manages a Firefox subprocess configured for use with WebDriver.
|
||||
*/
|
||||
export class Binary {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the Firefox binary to use. If not
|
||||
* specified, will attempt to locate Firefox on the current system.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
|
||||
/**
|
||||
* Add arguments to the command line used to start Firefox.
|
||||
* @param {...(string|!Array.<string>)} var_args Either the arguments to add as
|
||||
* varargs, or the arguments as an array.
|
||||
*/
|
||||
addArguments(...var_args: string[]): void;
|
||||
|
||||
/**
|
||||
* Launches Firefox and eturns a promise that will be fulfilled when the process
|
||||
* terminates.
|
||||
* @param {string} profile Path to the profile directory to use.
|
||||
* @return {!promise.Promise.<!exec.Result>} A promise for the process result.
|
||||
* @throws {Error} If this instance has already been started.
|
||||
*/
|
||||
launch(profile: string): webdriver.promise.Promise<any>;
|
||||
|
||||
/**
|
||||
* Kills the managed Firefox process.
|
||||
* @return {!promise.Promise} A promise for when the process has terminated.
|
||||
*/
|
||||
kill(): webdriver.promise.Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Models a Firefox proifle directory for use with the FirefoxDriver. The
|
||||
* {@code Proifle} directory uses an in-memory model until {@link #writeToDisk}
|
||||
* is called.
|
||||
*/
|
||||
export class Profile {
|
||||
/**
|
||||
* @param {string=} opt_dir Path to an existing Firefox profile directory to
|
||||
* use a template for this profile. If not specified, a blank profile will
|
||||
* be used.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_dir?: string);
|
||||
|
||||
/**
|
||||
* Registers an extension to be included with this profile.
|
||||
* @param {string} extension Path to the extension to include, as either an
|
||||
* unpacked extension directory or the path to a xpi file.
|
||||
*/
|
||||
addExtension(extension: string): void;
|
||||
|
||||
/**
|
||||
* Sets a desired preference for this profile.
|
||||
* @param {string} key The preference key.
|
||||
* @param {(string|number|boolean)} value The preference value.
|
||||
* @throws {Error} If attempting to set a frozen preference.
|
||||
*/
|
||||
setPreference(key: string, value: string): void;
|
||||
setPreference(key: string, value: number): void;
|
||||
setPreference(key: string, value: boolean): void;
|
||||
|
||||
/**
|
||||
* Returns the currently configured value of a profile preference. This does
|
||||
* not include any defaults defined in the profile's template directory user.js
|
||||
* file (if a template were specified on construction).
|
||||
* @param {string} key The desired preference.
|
||||
* @return {(string|number|boolean|undefined)} The current value of the
|
||||
* requested preference.
|
||||
*/
|
||||
getPreference(key: string): any;
|
||||
|
||||
/**
|
||||
* @return {number} The port this profile is currently configured to use, or
|
||||
* 0 if the port will be selected at random when the profile is written
|
||||
* to disk.
|
||||
*/
|
||||
getPort(): number;
|
||||
|
||||
/**
|
||||
* Sets the port to use for the WebDriver extension loaded by this profile.
|
||||
* @param {number} port The desired port, or 0 to use any free port.
|
||||
*/
|
||||
setPort(port: number): void;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the FirefoxDriver is configured to automatically
|
||||
* accept untrusted SSL certificates.
|
||||
*/
|
||||
acceptUntrustedCerts(): boolean;
|
||||
|
||||
/**
|
||||
* Sets whether the FirefoxDriver should automatically accept untrusted SSL
|
||||
* certificates.
|
||||
* @param {boolean} value .
|
||||
*/
|
||||
setAcceptUntrustedCerts(value: boolean): void;
|
||||
|
||||
/**
|
||||
* Sets whether to assume untrusted certificates come from untrusted issuers.
|
||||
* @param {boolean} value .
|
||||
*/
|
||||
setAssumeUntrustedCertIssuer(value: boolean): void;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether to assume untrusted certs come from untrusted
|
||||
* issuers.
|
||||
*/
|
||||
assumeUntrustedCertIssuer(): boolean;
|
||||
|
||||
/**
|
||||
* Sets whether to use native events with this profile.
|
||||
* @param {boolean} enabled .
|
||||
*/
|
||||
setNativeEventsEnabled(enabled: boolean): void;
|
||||
|
||||
/**
|
||||
* Returns whether native events are enabled in this profile.
|
||||
* @return {boolean} .
|
||||
*/
|
||||
nativeEventsEnabled(): boolean;
|
||||
|
||||
/**
|
||||
* Writes this profile to disk.
|
||||
* @param {boolean=} opt_excludeWebDriverExt Whether to exclude the WebDriver
|
||||
* extension from the generated profile. Used to reduce the size of an
|
||||
* {@link #encode() encoded profile} since the server will always install
|
||||
* the extension itself.
|
||||
* @return {!promise.Promise.<string>} A promise for the path to the new
|
||||
* profile directory.
|
||||
*/
|
||||
writeToDisk(opt_excludeWebDriverExt?: boolean): webdriver.promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* Encodes this profile as a zipped, base64 encoded directory.
|
||||
* @return {!promise.Promise.<string>} A promise for the encoded profile.
|
||||
*/
|
||||
encode(): webdriver.promise.Promise<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration options for the FirefoxDriver.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* Specify additional command line arguments that should be used when starting
|
||||
* the Firefox browser.
|
||||
*
|
||||
* @param {...(string|!Array<string>)} args The arguments to include.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Sets the browser to be in headless mode.
|
||||
*
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
headless(): Options;
|
||||
|
||||
/**
|
||||
* Sets the initial window size when running in
|
||||
* {@linkplain #headless headless} mode.
|
||||
*
|
||||
* @param {{width: number, height: number}} size The desired window size.
|
||||
* @return {!Options} A self reference.
|
||||
* @throws {TypeError} if width or height is unspecified, not a number, or
|
||||
* less than or equal to 0.
|
||||
*/
|
||||
windowSize(size: { width: number, height: number }): Options;
|
||||
|
||||
/**
|
||||
* Add extensions that should be installed when starting Firefox.
|
||||
*
|
||||
* @param {...string} paths The paths to the extension XPI files to install.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addExtensions(...paths: string[]): Options;
|
||||
|
||||
/**
|
||||
* @param {string} key the preference key.
|
||||
* @param {(string|number|boolean)} value the preference value.
|
||||
* @return {!Options} A self reference.
|
||||
* @throws {TypeError} if either the key or value has an invalid type.
|
||||
*/
|
||||
setPreference(key: string, value: string | number | boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the profile to use. The profile may be specified as a
|
||||
* {@link Profile} object or as the path to an existing Firefox profile to use
|
||||
* as a template.
|
||||
*
|
||||
* @param {(string|!Profile)} profile The profile to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProfile(profile: string | any): Options;
|
||||
|
||||
/**
|
||||
* Sets the binary to use. The binary may be specified as the path to a Firefox
|
||||
* executable, or as a {@link Binary} object.
|
||||
*
|
||||
* @param {(string|!Binary)} binary The binary to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setBinary(binary: string | any): Options;
|
||||
|
||||
/**
|
||||
* Sets the logging preferences for the new session.
|
||||
* @param {logging.Preferences} prefs The logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLoggingPreferences(prefs: webdriver.logging.Preferences): Options;
|
||||
|
||||
/**
|
||||
* Sets the proxy to use.
|
||||
*
|
||||
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setProxy(proxy: webdriver.ProxyConfig): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to use Mozilla's geckodriver to drive the browser. This option
|
||||
* is enabled by default and required for Firefox 47+.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable the geckodriver.
|
||||
* @see https://github.com/mozilla/geckodriver
|
||||
*/
|
||||
useGeckoDriver(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Converts these options to a {@link capabilities.Capabilities} instance.
|
||||
*
|
||||
* @return {!capabilities.Capabilities} A new capabilities object.
|
||||
*/
|
||||
toCapabilities(): webdriver.Capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string} .
|
||||
* @throws {Error}
|
||||
*/
|
||||
export function findWires(): string;
|
||||
|
||||
/**
|
||||
* @param {(string|!Binary)} binary .
|
||||
* @return {!remote.DriverService} .
|
||||
*/
|
||||
export function createWiresService(binary: string | any): remote.DriverService;
|
||||
|
||||
/**
|
||||
* @param {(Profile|string)} profile The profile to prepare.
|
||||
* @param {number} port The port the FirefoxDriver should listen on.
|
||||
* @return {!Promise<string>} a promise for the path to the profile directory.
|
||||
*/
|
||||
export function prepareProfile(profile: string | any, port: number): any;
|
||||
|
||||
/**
|
||||
* A WebDriver client for Firefox.
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new Firefox session.
|
||||
*
|
||||
* @param {(Options|capabilities.Capabilities|Object)=} opt_config The
|
||||
* configuration options for this driver, specified as either an
|
||||
* {@link Options} or {@link capabilities.Capabilities}, or as a raw hash
|
||||
* object.
|
||||
* @param {(http.Executor|remote.DriverService)=} opt_executor Either a
|
||||
* pre-configured command executor to use for communicating with an
|
||||
* externally managed remote end (which is assumed to already be running),
|
||||
* or the `DriverService` to use to start the geckodriver in a child
|
||||
* process.
|
||||
*
|
||||
* If an executor is provided, care should e taken not to use reuse it with
|
||||
* other clients as its internal command mappings will be updated to support
|
||||
* Firefox-specific commands.
|
||||
*
|
||||
* _This parameter may only be used with Mozilla's GeckoDriver._
|
||||
*
|
||||
* @param {promise.ControlFlow=} opt_flow The flow to
|
||||
* schedule commands through. Defaults to the active flow object.
|
||||
* @throws {Error} If a custom command executor is provided and the driver is
|
||||
* configured to use the legacy FirefoxDriver from the Selenium project.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: Options | webdriver.Capabilities, opt_executor?: http.Executor | remote.DriverService, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link selenium-webdriver/remote.DriverService} instances that manage
|
||||
* a [geckodriver](https://github.com/mozilla/geckodriver) server in a child
|
||||
* process.
|
||||
*/
|
||||
export class ServiceBuilder extends remote.DriverService.Builder {
|
||||
/**
|
||||
* @param {string=} opt_exe Path to the server executable to use. If omitted,
|
||||
* the builder will attempt to locate the geckodriver on the system PATH.
|
||||
*/
|
||||
constructor(opt_exe?: string);
|
||||
|
||||
/**
|
||||
* Enables verbose logging.
|
||||
*
|
||||
* @param {boolean=} opt_trace Whether to enable trace-level logging. By
|
||||
* default, only debug logging is enabled.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
*/
|
||||
enableVerboseLogging(opt_trace?: boolean): this;
|
||||
|
||||
/**
|
||||
* Sets the path to the executable Firefox binary that the geckodriver should
|
||||
* use. If this method is not called, this builder will attempt to locate
|
||||
* Firefox in the default installation location for the current platform.
|
||||
*
|
||||
* @param {(string|!Binary)} binary Path to the executable Firefox binary to use.
|
||||
* @return {!ServiceBuilder} A self reference.
|
||||
* @see Binary#locate()
|
||||
*/
|
||||
setFirefoxBinary(binary: string | Binary): this;
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
import * as webdriver from './index';
|
||||
|
||||
/**
|
||||
* Converts a headers map to a HTTP header block string.
|
||||
* @param {!Map<string, string>} headers The map to convert.
|
||||
* @return {string} The headers as a string.
|
||||
*/
|
||||
export function headersToString(headers: any): string;
|
||||
|
||||
/**
|
||||
* Represents a HTTP request message. This class is a 'partial' request and only
|
||||
* defines the path on the server to send a request to. It is each client's
|
||||
* responsibility to build the full URL for the final request.
|
||||
* @final
|
||||
*/
|
||||
export class Request {
|
||||
/**
|
||||
* @param {string} method The HTTP method to use for the request.
|
||||
* @param {string} path The path on the server to send the request to.
|
||||
* @param {Object=} opt_data This request's non-serialized JSON payload data.
|
||||
*/
|
||||
constructor(method: string, path: string, opt_data?: Object);
|
||||
|
||||
headers: Map<string, string>;
|
||||
method: string;
|
||||
path: string;
|
||||
data: Object;
|
||||
|
||||
/** @override */
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a HTTP response message.
|
||||
* @final
|
||||
*/
|
||||
export class Response {
|
||||
/**
|
||||
* @param {number} status The response code.
|
||||
* @param {!Object<string>} headers The response headers. All header names
|
||||
* will be converted to lowercase strings for consistent lookups.
|
||||
* @param {string} body The response body.
|
||||
*/
|
||||
constructor(status: number, headers: Object, body: string);
|
||||
|
||||
status: number;
|
||||
body: string;
|
||||
headers: Map<string, string>;
|
||||
|
||||
/** @override */
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export function post(path: string): any;
|
||||
export function del(path: string): any;
|
||||
export function get(path: string): any;
|
||||
export function resource(method: string, path: string): any;
|
||||
|
||||
/**
|
||||
* A basic HTTP client used to send messages to a remote end.
|
||||
*/
|
||||
export class HttpClient {
|
||||
/**
|
||||
* @param {string} serverUrl URL for the WebDriver server to send commands to.
|
||||
* @param {http.Agent=} opt_agent The agent to use for each request.
|
||||
* Defaults to `http.globalAgent`.
|
||||
* @param {?string=} opt_proxy The proxy to use for the connection to the
|
||||
* server. Default is to use no proxy.
|
||||
*/
|
||||
constructor(serverUrl: string, opt_agent?: any, opt_proxy?: string);
|
||||
|
||||
/**
|
||||
* Sends a request to the server. The client will automatically follow any
|
||||
* redirects returned by the server, fulfilling the returned promise with the
|
||||
* final response.
|
||||
*
|
||||
* @param {!HttpRequest} httpRequest The request to send.
|
||||
* @return {!promise.Promise<HttpResponse>} A promise that will be fulfilled
|
||||
* with the server's response.
|
||||
*/
|
||||
send(httpRequest: Request): webdriver.promise.Promise<Response>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a single HTTP request.
|
||||
* @param {!Object} options The request options.
|
||||
* @param {function(!HttpResponse)} onOk The function to call if the
|
||||
* request succeeds.
|
||||
* @param {function(!Error)} onError The function to call if the request fails.
|
||||
* @param {?string=} opt_data The data to send with the request.
|
||||
* @param {?string=} opt_proxy The proxy server to use for the request.
|
||||
*/
|
||||
export function sendRequest(options: Object, onOk: any, onError: any, opt_data?: string, opt_proxy?: string): any;
|
||||
|
||||
/**
|
||||
* A command executor that communicates with the server using HTTP + JSON.
|
||||
*
|
||||
* By default, each instance of this class will use the legacy wire protocol
|
||||
* from [Selenium project][json]. The executor will automatically switch to the
|
||||
* [W3C wire protocol][w3c] if the remote end returns a compliant response to
|
||||
* a new session command.
|
||||
*
|
||||
* [json]: https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
|
||||
* [w3c]: https://w3c.github.io/webdriver/webdriver-spec.html
|
||||
*
|
||||
* @implements {cmd.Executor}
|
||||
*/
|
||||
export class Executor {
|
||||
/**
|
||||
* @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 | webdriver.promise.IThenable<HttpClient>);
|
||||
|
||||
/**
|
||||
* Defines a new command for use with this executor. When a command is sent,
|
||||
* the {@code path} will be preprocessed using the command's parameters; any
|
||||
* path segments prefixed with ':' will be replaced by the parameter of the
|
||||
* same name. For example, given '/person/:name' and the parameters
|
||||
* '{name: 'Bob'}', the final command path will be '/person/Bob'.
|
||||
*
|
||||
* @param {string} name The command name.
|
||||
* @param {string} method The HTTP method to use when sending this command.
|
||||
* @param {string} path The path to send the command to, relative to
|
||||
* the WebDriver server's command root and of the form
|
||||
* '/path/:variable/segment'.
|
||||
*/
|
||||
defineCommand(name: string, method: string, path: string): void;
|
||||
|
||||
/** @override */
|
||||
execute(command: any): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} str .
|
||||
* @return {?} .
|
||||
*/
|
||||
export function tryParse(str: string): any;
|
||||
|
||||
/**
|
||||
* Callback used to parse {@link HttpResponse} objects from a
|
||||
* {@link HttpClient}.
|
||||
* @param {!HttpResponse} httpResponse The HTTP response to parse.
|
||||
* @param {boolean} w3c Whether the response should be processed using the
|
||||
* W3C wire protocol.
|
||||
* @return {{value: ?}} The parsed response.
|
||||
* @throws {WebDriverError} If the HTTP response is an error.
|
||||
*/
|
||||
export function parseHttpResponse(httpResponse: Response, w3c: boolean): any;
|
||||
|
||||
/**
|
||||
* Builds a fully qualified path using the given set of command parameters. Each
|
||||
* path segment prefixed with ':' will be replaced by the value of the
|
||||
* corresponding parameter. All parameters spliced into the path will be
|
||||
* removed from the parameter map.
|
||||
* @param {string} path The original resource path.
|
||||
* @param {!Object<*>} parameters The parameters object to splice into the path.
|
||||
* @return {string} The modified path.
|
||||
*/
|
||||
export function buildPath(path: string, parameters: Object): string;
|
||||
Vendored
+208
@@ -0,0 +1,208 @@
|
||||
import * as webdriver from './index';
|
||||
|
||||
/**
|
||||
* A WebDriver client for Microsoft's Internet Explorer.
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new session for Microsoft's Internet Explorer.
|
||||
*
|
||||
* @param {(capabilities.Capabilities|Options)=} opt_config The configuration
|
||||
* options.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to use,
|
||||
* or {@code null} to use the currently active flow.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: webdriver.Capabilities | Options, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
|
||||
/**
|
||||
* This function is a no-op as file detectors are not supported by this
|
||||
* implementation.
|
||||
* @override
|
||||
*/
|
||||
setFileDetector(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for managing IEDriver specific options.
|
||||
*/
|
||||
export class Options {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Extracts the IEDriver specific options from the given capabilities
|
||||
* object.
|
||||
* @param {!capabilities.Capabilities} caps The capabilities object.
|
||||
* @return {!Options} The IEDriver options.
|
||||
*/
|
||||
static fromCapabilities(caps: webdriver.Capabilities): Options;
|
||||
|
||||
/**
|
||||
* Whether to disable the protected mode settings check when the session is
|
||||
* created. Disbling this setting may lead to significant instability as the
|
||||
* browser may become unresponsive/hang. Only 'best effort' support is provided
|
||||
* when using this capability.
|
||||
*
|
||||
* For more information, refer to the IEDriver's
|
||||
* [required system configuration](http://goo.gl/eH0Yi3).
|
||||
*
|
||||
* @param {boolean} ignoreSettings Whether to ignore protected mode settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
introduceFlakinessByIgnoringProtectedModeSettings(ignoreSettings: boolean): Options;
|
||||
|
||||
/**
|
||||
* Indicates whether to skip the check that the browser's zoom level is set to
|
||||
* 100%.
|
||||
*
|
||||
* @param {boolean} ignore Whether to ignore the browser's zoom level settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
ignoreZoomSetting(ignore: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the initial URL loaded when IE starts. This is intended to be used with
|
||||
* {@link #ignoreProtectedModeSettings} to allow the user to initialize IE in
|
||||
* the proper Protected Mode zone. Setting this option may cause browser
|
||||
* instability or flaky and unresponsive code. Only 'best effort' support is
|
||||
* provided when using this option.
|
||||
*
|
||||
* @param {string} url The initial browser URL.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
initialBrowserUrl(url: string): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to enable persistent mouse hovering (true by default).
|
||||
* Persistent hovering is achieved by continuously firing mouse over events at
|
||||
* the last location the mouse cursor has been moved to.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable persistent hovering.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
enablePersistentHover(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether the driver should attempt to remove obsolete
|
||||
* {@linkplain webdriver.WebElement WebElements} from its internal cache on
|
||||
* page navigation (true by default). Disabling this option will cause the
|
||||
* driver to run with a larger memory footprint.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable element reference cleanup.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
enableElementCacheCleanup(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to require the IE window to have input focus before
|
||||
* performing any user interactions (i.e. mouse or keyboard events). This
|
||||
* option is disabled by default, but delivers much more accurate interaction
|
||||
* events when enabled.
|
||||
*
|
||||
* @param {boolean} require Whether to require window focus.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
requireWindowFocus(require: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures the timeout, in milliseconds, that the driver will attempt to
|
||||
* located and attach to a newly opened instance of Internet Explorer. The
|
||||
* default is zero, which indicates waiting indefinitely.
|
||||
*
|
||||
* @param {number} timeout How long to wait for IE.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
browserAttachTimeout(timeout: number): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to launch Internet Explorer using the CreateProcess API.
|
||||
* If this option is not specified, IE is launched using IELaunchURL, if
|
||||
* available. For IE 8 and above, this option requires the TabProcGrowth
|
||||
* registry value to be set to 0.
|
||||
*
|
||||
* @param {boolean} force Whether to use the CreateProcess API.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
forceCreateProcessApi(force: boolean): Options;
|
||||
|
||||
/**
|
||||
* Specifies command-line switches to use when launching Internet Explorer.
|
||||
* This is only valid when used with {@link #forceCreateProcessApi}.
|
||||
*
|
||||
* @param {...(string|!Array.<string>)} var_args The arguments to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addArguments(...var_args: string[]): Options;
|
||||
|
||||
/**
|
||||
* Configures whether proxies should be configured on a per-process basis. If
|
||||
* not set, setting a {@linkplain #setProxy proxy} will configure the system
|
||||
* proxy. The default behavior is to use the system proxy.
|
||||
*
|
||||
* @param {boolean} enable Whether to enable per-process proxy settings.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
usePerProcessProxy(enable: boolean): Options;
|
||||
|
||||
/**
|
||||
* Configures whether to clear the cache, cookies, history, and saved form data
|
||||
* before starting the browser. _Using this capability will clear session data
|
||||
* for all running instances of Internet Explorer, including those started
|
||||
* manually._
|
||||
*
|
||||
* @param {boolean} cleanSession Whether to clear all session data on startup.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
ensureCleanSession(cleanSession: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the path to the log file the driver should log to.
|
||||
* @param {string} file The log file path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLogFile(file: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the IEDriverServer's logging {@linkplain Level level}.
|
||||
* @param {Level} level The logging level.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLogLevel(level: webdriver.logging.Level): Options;
|
||||
|
||||
/**
|
||||
* Sets the IP address of the driver's host adapter.
|
||||
* @param {string} host The IP address to use.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setHost(host: string): Options;
|
||||
|
||||
/**
|
||||
* Sets the path of the temporary data directory to use.
|
||||
* @param {string} path The log file path.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setExtractPath(path: string): Options;
|
||||
|
||||
/**
|
||||
* Sets whether the driver should start in silent mode.
|
||||
* @param {boolean} silent Whether to run in silent mode.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
silent(silent: boolean): Options;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link capabilities.Capabilities}
|
||||
* object.
|
||||
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
|
||||
* merge these options into, if any.
|
||||
* @return {!capabilities.Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
|
||||
}
|
||||
+4825
File diff suppressed because it is too large
Load Diff
+242
@@ -0,0 +1,242 @@
|
||||
import * as webdriver from './index';
|
||||
|
||||
/**
|
||||
* A record object that defines the configuration options for a DriverService
|
||||
* instance.
|
||||
*
|
||||
* @record
|
||||
*/
|
||||
export interface ServiceOptions { }
|
||||
|
||||
/**
|
||||
* Manages the life and death of a native executable WebDriver server.
|
||||
*
|
||||
* It is expected that the driver server implements the
|
||||
* https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol.
|
||||
* Furthermore, the managed server should support multiple concurrent sessions,
|
||||
* so that this class may be reused for multiple clients.
|
||||
*/
|
||||
export class DriverService {
|
||||
/**
|
||||
* @param {string} executable Path to the executable to run.
|
||||
* @param {!ServiceOptions} options Configuration options for the service.
|
||||
*/
|
||||
constructor(executable: string, options: ServiceOptions);
|
||||
|
||||
/**
|
||||
* @return {!promise.Promise<string>} A promise that resolves to
|
||||
* the server's address.
|
||||
* @throws {Error} If the server has not been started.
|
||||
*/
|
||||
address(): webdriver.promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* Returns whether the underlying process is still running. This does not take
|
||||
* into account whether the process is in the process of shutting down.
|
||||
* @return {boolean} Whether the underlying service process is running.
|
||||
*/
|
||||
isRunning(): boolean;
|
||||
|
||||
/**
|
||||
* Starts the server if it is not already running.
|
||||
* @param {number=} opt_timeoutMs How long to wait, in milliseconds, for the
|
||||
* server to start accepting requests. Defaults to 30 seconds.
|
||||
* @return {!promise.Promise<string>} A promise that will resolve
|
||||
* to the server's base URL when it has started accepting requests. If the
|
||||
* timeout expires before the server has started, the promise will be
|
||||
* rejected.
|
||||
*/
|
||||
start(opt_timeoutMs?: number): webdriver.promise.Promise<string>;
|
||||
|
||||
/**
|
||||
* Stops the service if it is not currently running. This function will kill
|
||||
* the server immediately. To synchronize with the active control flow, use
|
||||
* {@link #stop()}.
|
||||
* @return {!promise.Promise} A promise that will be resolved when
|
||||
* the server has been stopped.
|
||||
*/
|
||||
kill(): webdriver.promise.Promise<any>;
|
||||
|
||||
/**
|
||||
* Schedules a task in the current control flow to stop the server if it is
|
||||
* currently running.
|
||||
* @return {!promise.Promise} A promise that will be resolved when
|
||||
* the server has been stopped.
|
||||
*/
|
||||
stop(): webdriver.promise.Promise<any>;
|
||||
}
|
||||
|
||||
export namespace DriverService {
|
||||
/**
|
||||
* Creates {@link DriverService} objects that manage a WebDriver server in a
|
||||
* child process.
|
||||
*/
|
||||
class Builder {
|
||||
/**
|
||||
* @param {string} exe Path to the executable to use. This executable must
|
||||
* accept the `--port` flag for defining the port to start the server on.
|
||||
* @throws {Error} If the provided executable path does not exist.
|
||||
*/
|
||||
constructor(exe: string);
|
||||
|
||||
/**
|
||||
* Define additional command line arguments to use when starting the server.
|
||||
*
|
||||
* @param {...CommandLineFlag} var_args The arguments to include.
|
||||
* @return {!THIS} A self reference.
|
||||
* @this {THIS}
|
||||
* @template THIS
|
||||
*/
|
||||
addArguments(...var_args: string[]): this;
|
||||
|
||||
/**
|
||||
* Sets the host name to access the server on. If specified, the
|
||||
* {@linkplain #setLoopback() loopback} setting will be ignored.
|
||||
*
|
||||
* @param {string} hostname
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setHostname(hostname: string): this;
|
||||
|
||||
/**
|
||||
* Sets whether the service should be accessed at this host's loopback
|
||||
* address.
|
||||
*
|
||||
* @param {boolean} loopback
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setLoopback(loopback: boolean): this;
|
||||
|
||||
/**
|
||||
* Sets the base path for WebDriver REST commands (e.g. "/wd/hub").
|
||||
* By default, the driver will accept commands relative to "/".
|
||||
*
|
||||
* @param {?string} basePath The base path to use, or `null` to use the
|
||||
* default.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setPath(basePath: string | null): this;
|
||||
|
||||
/**
|
||||
* Sets the port to start the server on.
|
||||
*
|
||||
* @param {number} port The port to use, or 0 for any free port.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
* @throws {Error} If an invalid port is specified.
|
||||
*/
|
||||
setPort(port: number): this;
|
||||
|
||||
/**
|
||||
* Defines the environment to start the server under. This setting will be
|
||||
* inherited by every browser session started by the server. By default, the
|
||||
* server will inherit the enviroment of the current process.
|
||||
*
|
||||
* @param {(Map<string, string>|Object<string, string>|null)} env The desired
|
||||
* environment to use, or `null` if the server should inherit the
|
||||
* current environment.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
*/
|
||||
setEnvironment(env: Map<string, string> | {[name: string]: string} | null): this;
|
||||
|
||||
/**
|
||||
* IO configuration for the spawned server process. For more information,
|
||||
* refer to the documentation of `child_process.spawn`.
|
||||
*
|
||||
* @param {StdIoOptions} config The desired IO configuration.
|
||||
* @return {!DriverService.Builder} A self reference.
|
||||
* @see https://nodejs.org/dist/latest-v4.x/docs/api/child_process.html#child_process_options_stdio
|
||||
*/
|
||||
setStdio(config: any): this;
|
||||
|
||||
/**
|
||||
* Creates a new DriverService using this instance's current configuration.
|
||||
*
|
||||
* @return {!DriverService} A new driver service.
|
||||
*/
|
||||
build(): DriverService;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages the life and death of the
|
||||
* <a href="http://selenium-release.storage.googleapis.com/index.html">
|
||||
* standalone Selenium server</a>.
|
||||
*/
|
||||
export class SeleniumServer extends DriverService {
|
||||
/**
|
||||
* @param {string} jar Path to the Selenium server jar.
|
||||
* @param {SeleniumServer.Options=} opt_options Configuration options for the
|
||||
* server.
|
||||
* @throws {Error} If the path to the Selenium jar is not specified or if an
|
||||
* invalid port is specified.
|
||||
**/
|
||||
constructor(jar: string, opt_options?: SeleniumServer.Options);
|
||||
}
|
||||
|
||||
export namespace SeleniumServer {
|
||||
/**
|
||||
* Options for the Selenium server
|
||||
*/
|
||||
interface Options {
|
||||
/** Whether the server should only be accessed on this host's loopback address.*/
|
||||
loopback?: boolean;
|
||||
|
||||
/** The port to start the server on (must be > 0). If the port is provided
|
||||
as a promise, the service will wait for the promise to resolve before starting. */
|
||||
port?: number|webdriver.promise.IThenable<number>;
|
||||
|
||||
/** The arguments to pass to the service. If a promise is provided, the
|
||||
service will wait for it to resolve before starting. */
|
||||
args?: string[]|webdriver.promise.IThenable<string[]>;
|
||||
|
||||
/** The arguments to pass to the JVM. If a promise is provided, the service
|
||||
will wait for it to resolve before starting. */
|
||||
jvmArgs?: string[]|webdriver.promise.IThenable<string[]>;
|
||||
|
||||
/** The environment variables that should be visible to the server process.
|
||||
Defaults to inheriting the current process's environment.*/
|
||||
env?: {[key: string]: string};
|
||||
|
||||
/** IO configuration for the spawned server process. For more information,
|
||||
refer to the documentation of `child_process.spawn`*/
|
||||
stdio?: string|Array<string|number>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link webdriver.FileDetector} that may be used when running
|
||||
* against a remote
|
||||
* [Selenium server](http://selenium-release.storage.googleapis.com/index.html).
|
||||
*
|
||||
* When a file path on the local machine running this script is entered with
|
||||
* {@link webdriver.WebElement#sendKeys WebElement#sendKeys}, this file detector
|
||||
* will transfer the specified file to the Selenium server's host; the sendKeys
|
||||
* command will be updated to use the transfered file's path.
|
||||
*
|
||||
* __Note:__ This class depends on a non-standard command supported on the
|
||||
* Java Selenium server. The file detector will fail if used with a server that
|
||||
* only supports standard WebDriver commands (such as the ChromeDriver).
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
export class FileDetector extends webdriver.FileDetector {
|
||||
/**
|
||||
* @constructor
|
||||
**/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Prepares a `file` for use with the remote browser. If the provided path
|
||||
* does not reference a normal file (i.e. it does not exist or is a
|
||||
* directory), then the promise returned by this method will be resolved with
|
||||
* the original file path. Otherwise, this method will upload the file to the
|
||||
* remote server, which will return the file's path on the remote system so
|
||||
* it may be referenced in subsequent commands.
|
||||
*
|
||||
* @param {!webdriver.WebDriver} driver The driver for the current browser.
|
||||
* @param {string} file The path of the file to process.
|
||||
* @return {!webdriver.promise.Promise<string>} A promise for the processed
|
||||
* file path.
|
||||
*/
|
||||
handleFile(driver: webdriver.WebDriver, file: string): webdriver.promise.Promise<string>;
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
import * as webdriver from './index';
|
||||
|
||||
export class Server { }
|
||||
|
||||
/**
|
||||
* @return {!Promise<string>} A promise that will resolve with the path
|
||||
* to Safari on the current system.
|
||||
*/
|
||||
export function findSafariExecutable(): any;
|
||||
|
||||
/**
|
||||
* @param {string} serverUrl The URL to connect to.
|
||||
* @return {!Promise<string>} A promise for the path to a file that Safari can
|
||||
* open on start-up to trigger a new connection to the WebSocket server.
|
||||
*/
|
||||
export function createConnectFile(serverUrl: string): any;
|
||||
|
||||
/**
|
||||
* Deletes all session data files if so desired.
|
||||
* @param {!Object} desiredCapabilities .
|
||||
* @return {!Array<promise.Promise>} A list of promises for the deleted files.
|
||||
*/
|
||||
export function cleanSession(desiredCapabilities: webdriver.Capabilities): any[];
|
||||
|
||||
/** @return {string} . */
|
||||
export function getRandomString(): string;
|
||||
|
||||
/**
|
||||
* @implements {command.Executor}
|
||||
*/
|
||||
export class CommandExecutor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration options specific to the {@link Driver SafariDriver}.
|
||||
*/
|
||||
export class Options {
|
||||
/**
|
||||
* Extracts the SafariDriver specific options from the given capabilities
|
||||
* object.
|
||||
* @param {!Capabilities} capabilities The capabilities object.
|
||||
* @return {!Options} The ChromeDriver options.
|
||||
*/
|
||||
static fromCapabilities(capabilities: webdriver.Capabilities): Options;
|
||||
|
||||
/**
|
||||
* Sets whether to force Safari to start with a clean session. Enabling this
|
||||
* option will cause all global browser data to be deleted.
|
||||
* @param {boolean} clean Whether to make sure the session has no cookies,
|
||||
* cache entries, local storage, or databases.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setCleanSession(clean: boolean): Options;
|
||||
|
||||
/**
|
||||
* Sets the logging preferences for the new session.
|
||||
* @param {!./lib/logging.Preferences} prefs The logging preferences.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
|
||||
|
||||
/**
|
||||
* Converts this options instance to a {@link Capabilities} object.
|
||||
* @param {Capabilities=} opt_capabilities The capabilities to
|
||||
* merge these options into, if any.
|
||||
* @return {!Capabilities} The capabilities.
|
||||
*/
|
||||
toCapabilities(opt_capabilities?: webdriver.Capabilities): webdriver.Capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* A WebDriver client for Safari. This class should never be instantiated
|
||||
* directly; instead, use the {@linkplain ./builder.Builder Builder}:
|
||||
*
|
||||
* var driver = new Builder()
|
||||
* .forBrowser('safari')
|
||||
* .build();
|
||||
*
|
||||
*/
|
||||
export class Driver extends webdriver.WebDriver {
|
||||
/**
|
||||
* Creates a new Safari session.
|
||||
*
|
||||
* @param {(Options|Capabilities)=} opt_config The configuration
|
||||
* options for the new session.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow to create
|
||||
* the driver under.
|
||||
* @return {!Driver} A new driver instance.
|
||||
*/
|
||||
static createSession(opt_config?: Options | webdriver.Capabilities, opt_flow?: webdriver.promise.ControlFlow): Driver;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import * as chrome from 'selenium-webdriver/chrome';
|
||||
import * as remote from 'selenium-webdriver/remote';
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
|
||||
function TestChromeDriver() {
|
||||
let driver: chrome.Driver = chrome.Driver.createSession();
|
||||
driver = chrome.Driver.createSession(webdriver.Capabilities.chrome());
|
||||
driver = chrome.Driver.createSession(webdriver.Capabilities.chrome(),
|
||||
new remote.DriverService('executable', new chrome.Options()),
|
||||
new webdriver.promise.ControlFlow());
|
||||
|
||||
let baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
|
||||
function TestChromeOptions() {
|
||||
let options: chrome.Options = new chrome.Options();
|
||||
options = chrome.Options.fromCapabilities(webdriver.Capabilities.chrome());
|
||||
|
||||
options = options.addArguments('a', 'b', 'c');
|
||||
options = options.addExtensions('a', 'b', 'c');
|
||||
options = options.excludeSwitches('a', 'b', 'c');
|
||||
options = options.detachDriver(true);
|
||||
options = options.setChromeBinaryPath('path');
|
||||
options = options.setChromeLogFile('logfile');
|
||||
options = options.setLocalState('state');
|
||||
options = options.androidActivity('com.example.Activity');
|
||||
options = options.headless();
|
||||
options = options.androidDeviceSerial('emulator-5554');
|
||||
options = options.androidChrome();
|
||||
options = options.androidPackage('com.android.chrome');
|
||||
options = options.androidProcess('com.android.chrome');
|
||||
options = options.androidUseRunningApp(true);
|
||||
options = options.setLoggingPrefs(new webdriver.logging.Preferences());
|
||||
options = options.setPerfLoggingPrefs({
|
||||
enableNetwork: true, enablePage: true, enableTimeline: true,
|
||||
tracingCategories: 'category', bufferUsageReportingInterval: 1000 });
|
||||
options = options.setProxy({ proxyType: 'proxyType' });
|
||||
options = options.setUserPreferences('preferences');
|
||||
let capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
capabilities = options.toCapabilities(webdriver.Capabilities.chrome());
|
||||
}
|
||||
|
||||
function TestServiceBuilder() {
|
||||
let builder: chrome.ServiceBuilder = new chrome.ServiceBuilder();
|
||||
builder = new chrome.ServiceBuilder('exe');
|
||||
|
||||
let anything: any = builder.build();
|
||||
builder = builder.setPort(8080);
|
||||
builder = builder.setAdbPort(5037);
|
||||
builder = builder.loggingTo('path');
|
||||
builder = builder.enableVerboseLogging();
|
||||
builder = builder.setNumHttpThreads(5);
|
||||
builder = builder.setPath('path');
|
||||
builder = builder.setStdio('config');
|
||||
builder = builder.setStdio(['A', 'B']);
|
||||
builder = builder.setEnvironment({ A: 'a', B: 'b' });
|
||||
}
|
||||
|
||||
function TestChromeModule() {
|
||||
let service: any = chrome.getDefaultService();
|
||||
chrome.setDefaultService(new remote.DriverService('executable', new chrome.Options()));
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import * as firefox from 'selenium-webdriver/firefox';
|
||||
import * as remote from 'selenium-webdriver/remote';
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
import * as http from 'selenium-webdriver/http';
|
||||
|
||||
function TestBinary() {
|
||||
let binary: firefox.Binary = new firefox.Binary();
|
||||
binary = new firefox.Binary('exe');
|
||||
|
||||
binary.addArguments('A', 'B', 'C');
|
||||
let promise: webdriver.promise.Promise<void> = binary.kill();
|
||||
binary.launch('profile').then((result: any) => {});
|
||||
}
|
||||
|
||||
function TestFirefoxDriver() {
|
||||
let driver: firefox.Driver = firefox.Driver.createSession();
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox());
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox(), new http.Executor(new http.HttpClient('http://someurl')));
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox(), new remote.DriverService('/dev/null', {}));
|
||||
driver = firefox.Driver.createSession(webdriver.Capabilities.firefox(), new remote.DriverService('/dev/null', {}), new webdriver.promise.ControlFlow());
|
||||
|
||||
let baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
|
||||
function TestFirefoxOptions() {
|
||||
let options: firefox.Options = new firefox.Options();
|
||||
|
||||
options = options.addArguments('foo', 'bar');
|
||||
options = options.windowSize({ width: 320, height: 480 });
|
||||
options = options.addExtensions('foo', 'bar');
|
||||
options = options.setPreference('a', 1);
|
||||
options = options.setPreference('a', true);
|
||||
options = options.setPreference('a', '1');
|
||||
options = options.setBinary('binary');
|
||||
options = options.setBinary(new firefox.Binary());
|
||||
options = options.setLoggingPreferences(new webdriver.logging.Preferences());
|
||||
options = options.setProfile('profile');
|
||||
options = options.setProfile(new firefox.Profile());
|
||||
options = options.setProxy({ proxyType: 'proxy' });
|
||||
let capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
}
|
||||
|
||||
function TestFirefoxProfile() {
|
||||
let profile: firefox.Profile = new firefox.Profile();
|
||||
profile = new firefox.Profile('dir');
|
||||
|
||||
let bool: boolean = profile.acceptUntrustedCerts();
|
||||
profile.addExtension('ext');
|
||||
bool = profile.assumeUntrustedCertIssuer();
|
||||
profile.encode().then((prof: string) => {});
|
||||
let num: number = profile.getPort();
|
||||
let anything: any = profile.getPreference('key');
|
||||
bool = profile.nativeEventsEnabled();
|
||||
profile.setAcceptUntrustedCerts(true);
|
||||
profile.setAssumeUntrustedCertIssuer(true);
|
||||
profile.setNativeEventsEnabled(true);
|
||||
profile.setPort(8080);
|
||||
profile.setPreference('key', 'value');
|
||||
profile.setPreference('key', 5);
|
||||
profile.setPreference('key', true);
|
||||
let stringPromise: webdriver.promise.Promise<string> = profile.writeToDisk();
|
||||
stringPromise = profile.writeToDisk(true);
|
||||
}
|
||||
|
||||
function TestServiceBuilder() {
|
||||
let builder: firefox.ServiceBuilder = new firefox.ServiceBuilder();
|
||||
builder = new firefox.ServiceBuilder('exe');
|
||||
|
||||
let anything: any = builder.build();
|
||||
builder = builder.setPort(8080);
|
||||
builder = builder.enableVerboseLogging();
|
||||
builder = builder.enableVerboseLogging(true);
|
||||
builder = builder.setFirefoxBinary('exe');
|
||||
builder = builder.setFirefoxBinary(new firefox.Binary());
|
||||
builder = builder.setPath('path');
|
||||
builder = builder.setStdio('config');
|
||||
builder = builder.setStdio(['A', 'B']);
|
||||
builder = builder.setEnvironment({ A: 'a', B: 'b' });
|
||||
}
|
||||
@@ -0,0 +1,991 @@
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
import * as chrome from 'selenium-webdriver/chrome';
|
||||
import * as edge from 'selenium-webdriver/edge';
|
||||
import * as firefox from 'selenium-webdriver/firefox';
|
||||
import * as http from 'selenium-webdriver/http';
|
||||
import * as remote from 'selenium-webdriver/remote';
|
||||
import * as safari from 'selenium-webdriver/safari';
|
||||
import * as testing from 'selenium-webdriver/testing';
|
||||
|
||||
function TestBuilder() {
|
||||
let builder: webdriver.Builder = new webdriver.Builder();
|
||||
|
||||
let driver: webdriver.WebDriver = builder.build();
|
||||
builder = builder.forBrowser('name');
|
||||
builder = builder.forBrowser('name', 'version');
|
||||
builder = builder.forBrowser('name', 'version', 'platform');
|
||||
|
||||
let cap: webdriver.Capabilities = builder.getCapabilities();
|
||||
let str: string = builder.getServerUrl();
|
||||
|
||||
builder = builder.setAlertBehavior('behavior');
|
||||
builder = builder.setChromeOptions(new chrome.Options());
|
||||
builder = builder.setChromeService(new chrome.ServiceBuilder());
|
||||
builder = builder.setControlFlow(new webdriver.promise.ControlFlow());
|
||||
builder = builder.setEdgeOptions(new edge.Options());
|
||||
builder = builder.setEdgeService(new edge.ServiceBuilder());
|
||||
builder = builder.setEnableNativeEvents(true);
|
||||
builder = builder.setFirefoxOptions(new firefox.Options());
|
||||
builder = builder.setFirefoxService(new firefox.ServiceBuilder());
|
||||
builder = builder.setLoggingPrefs(new webdriver.logging.Preferences());
|
||||
builder = builder.setLoggingPrefs({ key: 'value' });
|
||||
builder = builder.setProxy({ proxyType: 'type' });
|
||||
builder = builder.setSafariOptions(new safari.Options());
|
||||
builder = builder.setScrollBehavior(1);
|
||||
builder = builder.usingServer('http://someserver');
|
||||
builder = builder.withCapabilities(new webdriver.Capabilities());
|
||||
builder = builder.withCapabilities({ something: true });
|
||||
|
||||
const chromeOptions: chrome.Options = builder.getChromeOptions();
|
||||
const firefoxOptions: firefox.Options = builder.getFirefoxOptions();
|
||||
const safariOptions: safari.Options = builder.getSafariOptions();
|
||||
}
|
||||
|
||||
declare const promise: webdriver.promise.Promise<string>;
|
||||
|
||||
function TestActionSequence() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let sequence: webdriver.ActionSequence = new webdriver.ActionSequence(driver);
|
||||
let element: webdriver.WebElement = new webdriver.WebElement(driver, 'elementId');
|
||||
element = new webdriver.WebElement(driver, promise);
|
||||
|
||||
// Click
|
||||
sequence = sequence.click();
|
||||
sequence = sequence.click(webdriver.Button.LEFT);
|
||||
sequence = sequence.click(element);
|
||||
sequence = sequence.click(element, webdriver.Button.LEFT);
|
||||
|
||||
// DoubleClick
|
||||
sequence = sequence.doubleClick();
|
||||
sequence = sequence.doubleClick(webdriver.Button.LEFT);
|
||||
sequence = sequence.doubleClick(element);
|
||||
sequence = sequence.doubleClick(element, webdriver.Button.LEFT);
|
||||
|
||||
// DragAndDrop
|
||||
sequence = sequence.dragAndDrop(element, element);
|
||||
sequence = sequence.dragAndDrop(element, { x: 1, y: 2 });
|
||||
|
||||
// KeyDown
|
||||
sequence = sequence.keyDown(webdriver.Key.ADD);
|
||||
|
||||
// KeyUp
|
||||
sequence = sequence.keyUp(webdriver.Key.ADD);
|
||||
|
||||
// MouseDown
|
||||
sequence = sequence.mouseDown();
|
||||
sequence = sequence.mouseDown(webdriver.Button.LEFT);
|
||||
sequence = sequence.mouseDown(element);
|
||||
sequence = sequence.mouseDown(element, webdriver.Button.LEFT);
|
||||
|
||||
// MouseMove
|
||||
sequence = sequence.mouseMove(element);
|
||||
sequence = sequence.mouseMove({ x: 1, y: 1 });
|
||||
sequence = sequence.mouseMove(element, { x: 1, y: 2 });
|
||||
|
||||
// MouseUp
|
||||
sequence = sequence.mouseUp();
|
||||
sequence = sequence.mouseUp(webdriver.Button.LEFT);
|
||||
sequence = sequence.mouseUp(element);
|
||||
sequence = sequence.mouseUp(element, webdriver.Button.LEFT);
|
||||
|
||||
// SendKeys
|
||||
sequence = sequence.sendKeys('A', 'B', 'C');
|
||||
sequence = sequence.sendKeys('A', webdriver.Key.NULL);
|
||||
|
||||
sequence.perform().then(() => {});
|
||||
}
|
||||
|
||||
function TestTouchSequence() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
let element: webdriver.WebElement = new webdriver.WebElement(driver, 'elementId');
|
||||
|
||||
let sequence: webdriver.TouchSequence = new webdriver.TouchSequence(driver);
|
||||
|
||||
sequence = sequence.tap(element);
|
||||
sequence = sequence.doubleTap(element);
|
||||
sequence = sequence.longPress(element);
|
||||
sequence = sequence.tapAndHold({ x: 100, y: 100 });
|
||||
sequence = sequence.move({ x: 100, y: 100 });
|
||||
sequence = sequence.release({ x: 100, y: 100 });
|
||||
sequence = sequence.scroll({ x: 100, y: 100 });
|
||||
sequence = sequence.scrollFromElement(element, { x: 100, y: 100 });
|
||||
sequence = sequence.flick({ xspeed: 100, yspeed: 100 });
|
||||
sequence = sequence.flickElement(element, { x: 100, y: 100 }, 100);
|
||||
|
||||
sequence.perform().then(() => {});
|
||||
}
|
||||
|
||||
function TestAlert() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let alert: webdriver.Alert = driver.switchTo().alert();
|
||||
|
||||
alert.accept().then(() => {});
|
||||
alert.dismiss().then(() => {});
|
||||
alert.getText().then((text: string) => {});
|
||||
alert.sendKeys('ABC').then(() => {});
|
||||
}
|
||||
|
||||
function TestBrowser() {
|
||||
let browser: string;
|
||||
|
||||
browser = webdriver.Browser.ANDROID;
|
||||
browser = webdriver.Browser.CHROME;
|
||||
browser = webdriver.Browser.FIREFOX;
|
||||
browser = webdriver.Browser.HTMLUNIT;
|
||||
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;
|
||||
}
|
||||
|
||||
function TestButton() {
|
||||
let button: string;
|
||||
|
||||
button = webdriver.Button.LEFT;
|
||||
button = webdriver.Button.MIDDLE;
|
||||
button = webdriver.Button.RIGHT;
|
||||
}
|
||||
|
||||
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;
|
||||
capabilities = new webdriver.Capabilities(objCapabilities);
|
||||
|
||||
let anything: any = capabilities.get(webdriver.Capability.SECURE_SSL);
|
||||
let check: boolean = capabilities.has(webdriver.Capability.SECURE_SSL);
|
||||
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.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');
|
||||
|
||||
anything = capabilities.toJSON();
|
||||
|
||||
capabilities = webdriver.Capabilities.android();
|
||||
capabilities = webdriver.Capabilities.chrome();
|
||||
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.BROWSER_NAME;
|
||||
capability = webdriver.Capability.ELEMENT_SCROLL_BEHAVIOR;
|
||||
capability = webdriver.Capability.HANDLES_ALERTS;
|
||||
capability = webdriver.Capability.LOGGING_PREFS;
|
||||
capability = webdriver.Capability.NATIVE_EVENTS;
|
||||
capability = webdriver.Capability.PLATFORM;
|
||||
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;
|
||||
}
|
||||
|
||||
function TestCommand() {
|
||||
let command: webdriver.Command = new webdriver.Command(webdriver.CommandName.ADD_COOKIE);
|
||||
|
||||
let name: string = command.getName();
|
||||
let param: any = command.getParameter('param');
|
||||
|
||||
let params: any = command.getParameters();
|
||||
|
||||
command = command.setParameter('param', 123);
|
||||
command = command.setParameters({ param: 123 });
|
||||
}
|
||||
|
||||
function TestCommandName() {
|
||||
let command: string;
|
||||
|
||||
command = webdriver.CommandName.ACCEPT_ALERT;
|
||||
command = webdriver.CommandName.ADD_COOKIE;
|
||||
command = webdriver.CommandName.CLEAR_APP_CACHE;
|
||||
command = webdriver.CommandName.CLEAR_ELEMENT;
|
||||
command = webdriver.CommandName.CLEAR_LOCAL_STORAGE;
|
||||
command = webdriver.CommandName.CLEAR_SESSION_STORAGE;
|
||||
command = webdriver.CommandName.CLICK;
|
||||
command = webdriver.CommandName.CLICK_ELEMENT;
|
||||
command = webdriver.CommandName.CLOSE;
|
||||
command = webdriver.CommandName.DELETE_ALL_COOKIES;
|
||||
command = webdriver.CommandName.DELETE_COOKIE;
|
||||
command = webdriver.CommandName.DESCRIBE_SESSION;
|
||||
command = webdriver.CommandName.DISMISS_ALERT;
|
||||
command = webdriver.CommandName.DOUBLE_CLICK;
|
||||
command = webdriver.CommandName.ELEMENT_EQUALS;
|
||||
command = webdriver.CommandName.EXECUTE_ASYNC_SCRIPT;
|
||||
command = webdriver.CommandName.EXECUTE_SCRIPT;
|
||||
command = webdriver.CommandName.EXECUTE_SQL;
|
||||
command = webdriver.CommandName.FIND_CHILD_ELEMENT;
|
||||
command = webdriver.CommandName.FIND_CHILD_ELEMENTS;
|
||||
command = webdriver.CommandName.FIND_ELEMENT;
|
||||
command = webdriver.CommandName.FIND_ELEMENTS;
|
||||
command = webdriver.CommandName.GET;
|
||||
command = webdriver.CommandName.GET_ACTIVE_ELEMENT;
|
||||
command = webdriver.CommandName.GET_ALERT_TEXT;
|
||||
command = webdriver.CommandName.GET_ALL_COOKIES;
|
||||
command = webdriver.CommandName.GET_APP_CACHE;
|
||||
command = webdriver.CommandName.GET_APP_CACHE_STATUS;
|
||||
command = webdriver.CommandName.GET_AVAILABLE_LOG_TYPES;
|
||||
command = webdriver.CommandName.GET_COOKIE;
|
||||
command = webdriver.CommandName.GET_CURRENT_URL;
|
||||
command = webdriver.CommandName.GET_CURRENT_WINDOW_HANDLE;
|
||||
command = webdriver.CommandName.GET_ELEMENT_ATTRIBUTE;
|
||||
command = webdriver.CommandName.GET_ELEMENT_LOCATION;
|
||||
command = webdriver.CommandName.GET_ELEMENT_LOCATION_IN_VIEW;
|
||||
command = webdriver.CommandName.GET_ELEMENT_SIZE;
|
||||
command = webdriver.CommandName.GET_ELEMENT_TAG_NAME;
|
||||
command = webdriver.CommandName.GET_ELEMENT_TEXT;
|
||||
command = webdriver.CommandName.GET_ELEMENT_VALUE_OF_CSS_PROPERTY;
|
||||
command = webdriver.CommandName.GET_LOCAL_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.GET_LOCAL_STORAGE_KEYS;
|
||||
command = webdriver.CommandName.GET_LOCAL_STORAGE_SIZE;
|
||||
command = webdriver.CommandName.GET_LOCATION;
|
||||
command = webdriver.CommandName.GET_LOG;
|
||||
command = webdriver.CommandName.GET_PAGE_SOURCE;
|
||||
command = webdriver.CommandName.GET_SCREEN_ORIENTATION;
|
||||
command = webdriver.CommandName.GET_SERVER_STATUS;
|
||||
command = webdriver.CommandName.GET_SESSION_LOGS;
|
||||
command = webdriver.CommandName.GET_SESSION_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.GET_SESSION_STORAGE_KEYS;
|
||||
command = webdriver.CommandName.GET_SESSION_STORAGE_SIZE;
|
||||
command = webdriver.CommandName.GET_SESSIONS;
|
||||
command = webdriver.CommandName.GET_TITLE;
|
||||
command = webdriver.CommandName.GET_WINDOW_HANDLES;
|
||||
command = webdriver.CommandName.GET_WINDOW_POSITION;
|
||||
command = webdriver.CommandName.GET_WINDOW_SIZE;
|
||||
command = webdriver.CommandName.GO_BACK;
|
||||
command = webdriver.CommandName.GO_FORWARD;
|
||||
command = webdriver.CommandName.IMPLICITLY_WAIT;
|
||||
command = webdriver.CommandName.IS_BROWSER_ONLINE;
|
||||
command = webdriver.CommandName.IS_ELEMENT_DISPLAYED;
|
||||
command = webdriver.CommandName.IS_ELEMENT_ENABLED;
|
||||
command = webdriver.CommandName.IS_ELEMENT_SELECTED;
|
||||
command = webdriver.CommandName.MAXIMIZE_WINDOW;
|
||||
command = webdriver.CommandName.MOUSE_DOWN;
|
||||
command = webdriver.CommandName.MOUSE_UP;
|
||||
command = webdriver.CommandName.MOVE_TO;
|
||||
command = webdriver.CommandName.NEW_SESSION;
|
||||
command = webdriver.CommandName.QUIT;
|
||||
command = webdriver.CommandName.REFRESH;
|
||||
command = webdriver.CommandName.REMOVE_LOCAL_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.REMOVE_SESSION_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.SCREENSHOT;
|
||||
command = webdriver.CommandName.SEND_KEYS_TO_ACTIVE_ELEMENT;
|
||||
command = webdriver.CommandName.SEND_KEYS_TO_ELEMENT;
|
||||
command = webdriver.CommandName.SET_ALERT_TEXT;
|
||||
command = webdriver.CommandName.SET_BROWSER_ONLINE;
|
||||
command = webdriver.CommandName.SET_LOCAL_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.SET_LOCATION;
|
||||
command = webdriver.CommandName.SET_SCREEN_ORIENTATION;
|
||||
command = webdriver.CommandName.SET_SCRIPT_TIMEOUT;
|
||||
command = webdriver.CommandName.SET_SESSION_STORAGE_ITEM;
|
||||
command = webdriver.CommandName.SET_TIMEOUT;
|
||||
command = webdriver.CommandName.SET_WINDOW_POSITION;
|
||||
command = webdriver.CommandName.SET_WINDOW_SIZE;
|
||||
command = webdriver.CommandName.SUBMIT_ELEMENT;
|
||||
command = webdriver.CommandName.SWITCH_TO_FRAME;
|
||||
command = webdriver.CommandName.SWITCH_TO_WINDOW;
|
||||
command = webdriver.CommandName.TOUCH_DOUBLE_TAP;
|
||||
command = webdriver.CommandName.TOUCH_DOWN;
|
||||
command = webdriver.CommandName.TOUCH_FLICK;
|
||||
command = webdriver.CommandName.TOUCH_LONG_PRESS;
|
||||
command = webdriver.CommandName.TOUCH_MOVE;
|
||||
command = webdriver.CommandName.TOUCH_SCROLL;
|
||||
command = webdriver.CommandName.TOUCH_SINGLE_TAP;
|
||||
command = webdriver.CommandName.TOUCH_UP;
|
||||
}
|
||||
|
||||
function TestEventEmitter() {
|
||||
let emitter: webdriver.EventEmitter = new webdriver.EventEmitter();
|
||||
|
||||
let callback = (a: number, b: number, c: number) => {};
|
||||
|
||||
emitter = emitter.addListener('ABC', callback);
|
||||
emitter = emitter.addListener('ABC', callback, this);
|
||||
|
||||
emitter.emit('ABC', 1, 2, 3);
|
||||
|
||||
let listeners = emitter.listeners('ABC');
|
||||
if (listeners[0].oneshot) {
|
||||
listeners[0].fn.apply(listeners[0].scope);
|
||||
}
|
||||
let length: number = listeners.length;
|
||||
let listenerInfo = listeners[0];
|
||||
if (listenerInfo.oneshot) {
|
||||
listenerInfo.fn.apply(listenerInfo.scope, [1, 2, 3]);
|
||||
}
|
||||
|
||||
emitter = emitter.on('ABC', callback);
|
||||
emitter = emitter.on('ABC', callback, this);
|
||||
|
||||
emitter = emitter.once('ABC', callback);
|
||||
emitter = emitter.once('ABC', callback, this);
|
||||
|
||||
emitter = emitter.removeListener('ABC', callback);
|
||||
|
||||
emitter.removeAllListeners('ABC');
|
||||
emitter.removeAllListeners();
|
||||
}
|
||||
|
||||
function TestKey() {
|
||||
let key: string;
|
||||
|
||||
key = webdriver.Key.ADD;
|
||||
key = webdriver.Key.ALT;
|
||||
key = webdriver.Key.ARROW_DOWN;
|
||||
key = webdriver.Key.ARROW_LEFT;
|
||||
key = webdriver.Key.ARROW_RIGHT;
|
||||
key = webdriver.Key.ARROW_UP;
|
||||
key = webdriver.Key.BACK_SPACE;
|
||||
key = webdriver.Key.CANCEL;
|
||||
key = webdriver.Key.CLEAR;
|
||||
key = webdriver.Key.COMMAND;
|
||||
key = webdriver.Key.CONTROL;
|
||||
key = webdriver.Key.DECIMAL;
|
||||
key = webdriver.Key.DELETE;
|
||||
key = webdriver.Key.DIVIDE;
|
||||
key = webdriver.Key.DOWN;
|
||||
key = webdriver.Key.END;
|
||||
key = webdriver.Key.ENTER;
|
||||
key = webdriver.Key.EQUALS;
|
||||
key = webdriver.Key.ESCAPE;
|
||||
key = webdriver.Key.F1;
|
||||
key = webdriver.Key.F2;
|
||||
key = webdriver.Key.F3;
|
||||
key = webdriver.Key.F4;
|
||||
key = webdriver.Key.F5;
|
||||
key = webdriver.Key.F6;
|
||||
key = webdriver.Key.F7;
|
||||
key = webdriver.Key.F8;
|
||||
key = webdriver.Key.F9;
|
||||
key = webdriver.Key.F10;
|
||||
key = webdriver.Key.F11;
|
||||
key = webdriver.Key.F12;
|
||||
key = webdriver.Key.HELP;
|
||||
key = webdriver.Key.HOME;
|
||||
key = webdriver.Key.INSERT;
|
||||
key = webdriver.Key.LEFT;
|
||||
key = webdriver.Key.META;
|
||||
key = webdriver.Key.MULTIPLY;
|
||||
key = webdriver.Key.NULL;
|
||||
key = webdriver.Key.NUMPAD0;
|
||||
key = webdriver.Key.NUMPAD1;
|
||||
key = webdriver.Key.NUMPAD2;
|
||||
key = webdriver.Key.NUMPAD3;
|
||||
key = webdriver.Key.NUMPAD4;
|
||||
key = webdriver.Key.NUMPAD5;
|
||||
key = webdriver.Key.NUMPAD6;
|
||||
key = webdriver.Key.NUMPAD7;
|
||||
key = webdriver.Key.NUMPAD8;
|
||||
key = webdriver.Key.NUMPAD9;
|
||||
key = webdriver.Key.PAGE_DOWN;
|
||||
key = webdriver.Key.PAGE_UP;
|
||||
key = webdriver.Key.PAUSE;
|
||||
key = webdriver.Key.RETURN;
|
||||
key = webdriver.Key.RIGHT;
|
||||
key = webdriver.Key.SEMICOLON;
|
||||
key = webdriver.Key.SEPARATOR;
|
||||
key = webdriver.Key.SHIFT;
|
||||
key = webdriver.Key.SPACE;
|
||||
key = webdriver.Key.SUBTRACT;
|
||||
key = webdriver.Key.TAB;
|
||||
key = webdriver.Key.UP;
|
||||
}
|
||||
|
||||
function TestBy() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let locator: webdriver.By = new webdriver.By('class name', 'class');
|
||||
|
||||
let str: string = locator.toString();
|
||||
|
||||
locator = webdriver.By.className('class');
|
||||
locator = webdriver.By.css('css');
|
||||
locator = webdriver.By.id('id');
|
||||
locator = webdriver.By.linkText('link');
|
||||
locator = webdriver.By.name('name');
|
||||
locator = webdriver.By.partialLinkText('text');
|
||||
locator = webdriver.By.tagName('tag');
|
||||
locator = webdriver.By.xpath('xpath');
|
||||
|
||||
// Can import 'By' without import declarations
|
||||
let By = webdriver.By;
|
||||
|
||||
let locatorHash: webdriver.ByHash;
|
||||
locatorHash = { className: 'class' };
|
||||
locatorHash = { css: 'css' };
|
||||
locatorHash = { id: 'id' };
|
||||
locatorHash = { linkText: 'link' };
|
||||
locatorHash = { name: 'name' };
|
||||
locatorHash = { partialLinkText: 'text' };
|
||||
locatorHash = { tagName: 'tag' };
|
||||
locatorHash = { xpath: 'xpath' };
|
||||
|
||||
webdriver.By.js('script', 1, 2, 3)(driver).then((abc: number) => {});
|
||||
}
|
||||
|
||||
function TestSession() {
|
||||
let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
|
||||
let capabilitiesObj: any = {};
|
||||
capabilitiesObj[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.ANDROID;
|
||||
capabilitiesObj[webdriver.Capability.PLATFORM] = 'ANDROID';
|
||||
session = new webdriver.Session('ABC', capabilitiesObj);
|
||||
|
||||
let capabilities: webdriver.Capabilities = session.getCapabilities();
|
||||
let capability: any = session.getCapability(webdriver.Capability.BROWSER_NAME);
|
||||
let id: string = session.getId();
|
||||
let data: string = session.toJSON();
|
||||
}
|
||||
|
||||
function TestWebDriverFileDetector() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let fileDetector: webdriver.FileDetector = new webdriver.FileDetector();
|
||||
|
||||
fileDetector.handleFile(driver, 'path/to/file').then((path: string) => {});
|
||||
}
|
||||
|
||||
function TestWebDriverLogs() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let logs: webdriver.Logs = new webdriver.Logs(driver);
|
||||
|
||||
logs.get(webdriver.logging.Type.BROWSER).then((entries: webdriver.logging.Entry[]) => {});
|
||||
logs.getAvailableLogTypes().then((types: string[]) => {});
|
||||
}
|
||||
|
||||
function TestWebDriverNavigation() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let navigation: webdriver.Navigation = new webdriver.Navigation(driver);
|
||||
|
||||
navigation.back().then(() => {});
|
||||
navigation.forward().then(() => {});
|
||||
navigation.refresh().then(() => {});
|
||||
navigation.to('http://google.com').then(() => {});
|
||||
}
|
||||
|
||||
function TestWebDriverOptions() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let options: webdriver.Options = new webdriver.Options(driver);
|
||||
let promise: webdriver.promise.Promise<void>;
|
||||
|
||||
let name: string = 'name';
|
||||
let value: string = 'value';
|
||||
let path: string = 'path';
|
||||
let domain: string = 'domain';
|
||||
let secure: boolean = true;
|
||||
let 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, 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');
|
||||
options.getCookie('name').then((cookie: webdriver.IWebDriverCookie) => {
|
||||
let expiry: number | undefined = cookie.expiry;
|
||||
});
|
||||
options.getCookies().then((cookies: webdriver.IWebDriverCookie[]) => { });
|
||||
|
||||
let logs: webdriver.Logs = options.logs();
|
||||
let timeouts: webdriver.Timeouts = options.timeouts();
|
||||
let window: webdriver.Window = options.window();
|
||||
}
|
||||
|
||||
function TestWebDriverTargetLocator() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let locator: webdriver.TargetLocator = new webdriver.TargetLocator(driver);
|
||||
let promise: webdriver.promise.Promise<void>;
|
||||
|
||||
let element: webdriver.WebElement = locator.activeElement();
|
||||
let alert: webdriver.Alert = locator.alert();
|
||||
promise = locator.defaultContent();
|
||||
promise = locator.frame(1);
|
||||
promise = locator.window('nameOrHandle');
|
||||
}
|
||||
|
||||
function TestWebDriverTimeouts() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let timeouts: webdriver.Timeouts = new webdriver.Timeouts(driver);
|
||||
let promise: webdriver.promise.Promise<void>;
|
||||
|
||||
promise = timeouts.implicitlyWait(123);
|
||||
promise = timeouts.pageLoadTimeout(123);
|
||||
promise = timeouts.setScriptTimeout(123);
|
||||
}
|
||||
|
||||
function TestWebDriverWindow() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let window: webdriver.Window = new webdriver.Window(driver);
|
||||
let locationPromise: webdriver.promise.Promise<webdriver.ILocation>;
|
||||
let sizePromise: webdriver.promise.Promise<webdriver.ISize>;
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
|
||||
locationPromise = window.getPosition();
|
||||
sizePromise = window.getSize();
|
||||
voidPromise = window.maximize();
|
||||
voidPromise = window.setPosition(12, 34);
|
||||
voidPromise = window.setSize(12, 34);
|
||||
}
|
||||
|
||||
declare const sessionPromise: webdriver.promise.Promise<webdriver.Session>;
|
||||
declare let booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
declare const booleanCondition: webdriver.Condition<boolean>;
|
||||
declare const webElementCondition: webdriver.WebElementCondition;
|
||||
|
||||
function TestWebDriver() {
|
||||
let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
|
||||
let httpClient: http.HttpClient = new http.HttpClient('http://someserver');
|
||||
let executor: http.Executor = new http.Executor(httpClient);
|
||||
let flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow();
|
||||
let driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor);
|
||||
driver = new webdriver.WebDriver(session, executor, flow);
|
||||
driver = new webdriver.WebDriver(sessionPromise, executor);
|
||||
driver = new webdriver.WebDriver(sessionPromise, executor, flow);
|
||||
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
let stringPromise: webdriver.promise.Promise<string>;
|
||||
let webElementPromise: webdriver.WebElementPromise;
|
||||
|
||||
let actions: webdriver.ActionSequence = driver.actions();
|
||||
let touchActions: webdriver.TouchSequence = driver.touchActions();
|
||||
|
||||
// call
|
||||
stringPromise = driver.call<string>(() => 'value');
|
||||
stringPromise = driver.call<string>(() => stringPromise);
|
||||
stringPromise = driver.call<string>(() => 'value', driver);
|
||||
stringPromise = driver.call<string>((a: number) => 'value', driver, 1);
|
||||
|
||||
voidPromise = driver.close();
|
||||
flow = driver.controlFlow();
|
||||
|
||||
// executeAsyncScript
|
||||
stringPromise = driver.executeAsyncScript<string>('function(){}');
|
||||
stringPromise = driver.executeAsyncScript<string>('function(){}', 1, 2, 3);
|
||||
stringPromise = driver.executeAsyncScript<string>(() => {});
|
||||
stringPromise = driver.executeAsyncScript<string>((a: number) => {}, 1);
|
||||
|
||||
// executeScript
|
||||
stringPromise = driver.executeScript<string>('function(){}');
|
||||
stringPromise = driver.executeScript<string>('function(){}', 1, 2, 3);
|
||||
stringPromise = driver.executeScript<string>(() => {});
|
||||
stringPromise = driver.executeScript<string>((a: number) => {}, 1);
|
||||
|
||||
// findElement
|
||||
let element: webdriver.WebElement;
|
||||
element = driver.findElement(webdriver.By.id('ABC'));
|
||||
element = driver.findElement(webdriver.By.js('function(){}'));
|
||||
|
||||
// findElements
|
||||
driver.findElements(webdriver.By.className('ABC')).then((elements: webdriver.WebElement[]) => {});
|
||||
driver.findElements(webdriver.By.js('function(){}')).then((elements: webdriver.WebElement[]) => {});
|
||||
|
||||
voidPromise = driver.get('http://www.google.com');
|
||||
driver.getAllWindowHandles().then((handles: string[]) => {});
|
||||
driver.getCapabilities().then((caps: webdriver.Capabilities) => {});
|
||||
stringPromise = driver.getCurrentUrl();
|
||||
stringPromise = driver.getPageSource();
|
||||
driver.getSession().then((session: webdriver.Session) => {});
|
||||
stringPromise = driver.getTitle();
|
||||
stringPromise = driver.getWindowHandle();
|
||||
|
||||
let options: webdriver.Options = driver.manage();
|
||||
let navigation: webdriver.Navigation = driver.navigate();
|
||||
let locator: webdriver.TargetLocator = driver.switchTo();
|
||||
|
||||
let fileDetector: webdriver.FileDetector = new webdriver.FileDetector();
|
||||
driver.setFileDetector(fileDetector);
|
||||
|
||||
voidPromise = driver.quit();
|
||||
voidPromise = driver.schedule<void>(new webdriver.Command(webdriver.CommandName.CLICK), 'ABC');
|
||||
voidPromise = driver.sleep(123);
|
||||
stringPromise = driver.takeScreenshot();
|
||||
|
||||
booleanPromise = driver.wait(booleanPromise);
|
||||
booleanPromise = driver.wait(booleanCondition);
|
||||
booleanPromise = driver.wait((driver: webdriver.WebDriver) => true);
|
||||
booleanPromise = driver.wait((driver: webdriver.WebDriver) => Promise.resolve(true));
|
||||
booleanPromise = driver.wait((driver: webdriver.WebDriver) => webdriver.promise.Promise.resolve(true));
|
||||
booleanPromise = driver.wait(booleanPromise, 123);
|
||||
booleanPromise = driver.wait(booleanPromise, 123, 'Message');
|
||||
webElementPromise = driver.wait(webElementCondition);
|
||||
voidPromise = driver.wait(webElementCondition).click();
|
||||
|
||||
driver = webdriver.WebDriver.attachToSession(executor, 'ABC');
|
||||
driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android());
|
||||
}
|
||||
|
||||
declare const serializable: webdriver.Serializable<string>;
|
||||
|
||||
function TestSerializable() {
|
||||
let serial: string | webdriver.promise.IThenable<string> = serializable.serialize();
|
||||
}
|
||||
|
||||
function TestWebElement() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let element: webdriver.WebElement;
|
||||
|
||||
element = new webdriver.WebElement(driver, 'elementId');
|
||||
element = new webdriver.WebElement(driver, promise);
|
||||
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
let stringPromise: webdriver.promise.Promise<string>;
|
||||
let booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
|
||||
voidPromise = element.clear();
|
||||
voidPromise = element.click();
|
||||
|
||||
element = element.findElement(webdriver.By.id('ABC'));
|
||||
element = element.findElement({id: 'ABC'});
|
||||
element.findElements({className: 'ABC'}).then((elements: webdriver.WebElement[]) => { });
|
||||
|
||||
stringPromise = element.getAttribute('class');
|
||||
stringPromise = element.getCssValue('display');
|
||||
driver = element.getDriver();
|
||||
element.getLocation().then((location: webdriver.ILocation) => {});
|
||||
element.getSize().then((size: webdriver.ISize) => {});
|
||||
stringPromise = element.getTagName();
|
||||
stringPromise = element.getText();
|
||||
booleanPromise = element.isDisplayed();
|
||||
booleanPromise = element.isEnabled();
|
||||
booleanPromise = element.isSelected();
|
||||
voidPromise = element.sendKeys('A', 'B', 'C');
|
||||
voidPromise = element.sendKeys(1, 2, 3);
|
||||
voidPromise = element.sendKeys(webdriver.Key.BACK_SPACE);
|
||||
voidPromise = element.sendKeys(stringPromise, stringPromise, stringPromise);
|
||||
voidPromise = element.sendKeys('A', 1, webdriver.Key.BACK_SPACE, stringPromise);
|
||||
voidPromise = element.submit();
|
||||
element.getId().then((id: string) => {});
|
||||
element.serialize().then((id: webdriver.IWebElementId) => {});
|
||||
|
||||
booleanPromise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, 'elementId'));
|
||||
}
|
||||
|
||||
function TestWebElementPromise() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let elementPromise: webdriver.WebElementPromise = driver.findElement(webdriver.By.id('id'));
|
||||
|
||||
elementPromise.then();
|
||||
elementPromise.then((element: webdriver.WebElement) => {});
|
||||
elementPromise.then((element: webdriver.WebElement) => {}, (error: any) => {});
|
||||
elementPromise.then((element: webdriver.WebElement) => 'foo', (error: any) => {}).then((result: string) => {});
|
||||
}
|
||||
|
||||
function TestLogging() {
|
||||
let preferences: webdriver.logging.Preferences = new webdriver.logging.Preferences();
|
||||
preferences.setLevel(webdriver.logging.Type.BROWSER, webdriver.logging.Level.ALL);
|
||||
let prefs: any = preferences.toJSON();
|
||||
|
||||
let level: webdriver.logging.Level = webdriver.logging.getLevel('OFF');
|
||||
level = webdriver.logging.getLevel(1);
|
||||
|
||||
level = webdriver.logging.Level.ALL;
|
||||
level = webdriver.logging.Level.DEBUG;
|
||||
level = webdriver.logging.Level.INFO;
|
||||
level = webdriver.logging.Level.OFF;
|
||||
level = webdriver.logging.Level.SEVERE;
|
||||
level = webdriver.logging.Level.WARNING;
|
||||
|
||||
let name: string = level.name;
|
||||
let value: number = level.value;
|
||||
|
||||
let type: string;
|
||||
type = webdriver.logging.Type.BROWSER;
|
||||
type = webdriver.logging.Type.CLIENT;
|
||||
type = webdriver.logging.Type.DRIVER;
|
||||
type = webdriver.logging.Type.PERFORMANCE;
|
||||
type = webdriver.logging.Type.SERVER;
|
||||
|
||||
let logger: webdriver.logging.Logger = webdriver.logging.getLogger();
|
||||
webdriver.logging.addConsoleHandler();
|
||||
webdriver.logging.addConsoleHandler(logger);
|
||||
webdriver.logging.removeConsoleHandler();
|
||||
webdriver.logging.removeConsoleHandler(logger);
|
||||
}
|
||||
|
||||
function TestLoggingEntry() {
|
||||
let entry: webdriver.logging.Entry;
|
||||
|
||||
entry = new webdriver.logging.Entry(webdriver.logging.Level.ALL, 'ABC');
|
||||
entry = new webdriver.logging.Entry('ALL', 'ABC');
|
||||
entry = new webdriver.logging.Entry(webdriver.logging.Level.ALL, 'ABC', 123);
|
||||
entry = new webdriver.logging.Entry('ALL', 'ABC', 123);
|
||||
entry = new webdriver.logging.Entry(webdriver.logging.Level.ALL, 'ABC', 123, webdriver.logging.Type.BROWSER);
|
||||
entry = new webdriver.logging.Entry('ALL', 'ABC', 123, webdriver.logging.Type.BROWSER);
|
||||
|
||||
let entryObj: any = entry.toJSON();
|
||||
|
||||
let message: string = entry.message;
|
||||
let timestamp: number = entry.timestamp;
|
||||
let type: string = entry.type;
|
||||
}
|
||||
|
||||
declare let stringPromise: webdriver.promise.Promise<string>;
|
||||
|
||||
function TestPromiseModule() {
|
||||
let cancellationError: webdriver.promise.CancellationError = new webdriver.promise.CancellationError();
|
||||
cancellationError = new webdriver.promise.CancellationError('message');
|
||||
let str: string = cancellationError.message;
|
||||
str = cancellationError.name;
|
||||
|
||||
let numberPromise: webdriver.promise.Promise<number>;
|
||||
let booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
let voidPromise: webdriver.promise.Promise<void>;
|
||||
|
||||
webdriver.promise.all([stringPromise]).then((values: string[]) => {});
|
||||
|
||||
webdriver.promise.asap('abc', (value: any) => true);
|
||||
webdriver.promise.asap('abc', (value: any) => {}, (err: any) => 'ABC');
|
||||
|
||||
stringPromise = webdriver.promise.checkedNodeCall<string>((err: any, value: any) => 'abc');
|
||||
|
||||
webdriver.promise.consume(() => {
|
||||
return 5;
|
||||
}).then((value: number) => {});
|
||||
webdriver.promise.consume(() => {
|
||||
return 5;
|
||||
}, this).then((value: number) => {});
|
||||
webdriver.promise.consume((a: number, b: number, c: number) => 5, this, 1, 2, 3)
|
||||
.then((value: number) => {});
|
||||
|
||||
let numbersPromise: webdriver.promise.Promise<number[]> = webdriver.promise.filter([1, 2, 3], (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.filter([1, 2, 3], (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = webdriver.promise.filter(numbersPromise, (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.filter(numbersPromise, (element: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
numbersPromise = webdriver.promise.map([1, 2, 3], (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.map([1, 2, 3], (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = webdriver.promise.map(numbersPromise, (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = webdriver.promise.map(numbersPromise, (el: number, type: any, index: number, arr: number[]) => {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
let flow: webdriver.promise.ControlFlow = webdriver.promise.controlFlow();
|
||||
|
||||
stringPromise = webdriver.promise.createFlow<string>((newFlow: webdriver.promise.ControlFlow) => 'ABC');
|
||||
|
||||
let deferred: webdriver.promise.Deferred<string>;
|
||||
deferred = webdriver.promise.defer<string>();
|
||||
deferred = webdriver.promise.defer<string>();
|
||||
|
||||
stringPromise = deferred.promise;
|
||||
|
||||
deferred.fulfill('ABC');
|
||||
deferred.reject('error');
|
||||
|
||||
voidPromise = webdriver.promise.delayed(123);
|
||||
|
||||
voidPromise = webdriver.promise.fulfilled<void>();
|
||||
stringPromise = webdriver.promise.fulfilled('abc');
|
||||
|
||||
stringPromise = webdriver.promise.fullyResolved<string>('abc');
|
||||
|
||||
let bool: boolean = webdriver.promise.isGenerator(() => {});
|
||||
let isPromise: boolean = webdriver.promise.isPromise('ABC');
|
||||
|
||||
stringPromise = webdriver.promise.rejected<string>('{a: 123}');
|
||||
|
||||
webdriver.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
|
||||
|
||||
numberPromise = webdriver.promise.when('abc', (value: any) => 123, (err: Error) => 123);
|
||||
}
|
||||
|
||||
function TestUntilModule() {
|
||||
let driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
let conditionB: webdriver.Condition<boolean> = new webdriver.Condition<boolean>('message', (driver: webdriver.WebDriver) => true);
|
||||
let conditionBBase: webdriver.Condition<boolean> = conditionB;
|
||||
let conditionWebElement: webdriver.WebElementCondition;
|
||||
let conditionWebElements: webdriver.Condition<webdriver.WebElement[]>;
|
||||
|
||||
conditionB = webdriver.until.ableToSwitchToFrame(5);
|
||||
let conditionAlert: webdriver.Condition<webdriver.Alert> = webdriver.until.alertIsPresent();
|
||||
let el: webdriver.WebElement = driver.findElement(webdriver.By.id('id'));
|
||||
conditionB = webdriver.until.stalenessOf(el);
|
||||
conditionB = webdriver.until.titleContains('text');
|
||||
conditionB = webdriver.until.titleIs('text');
|
||||
conditionB = webdriver.until.titleMatches(/text/);
|
||||
conditionB = webdriver.until.urlContains('text');
|
||||
conditionB = webdriver.until.urlIs('text');
|
||||
conditionB = webdriver.until.urlMatches(/text/);
|
||||
|
||||
conditionWebElement = webdriver.until.elementIsDisabled(el);
|
||||
conditionWebElement = webdriver.until.elementIsEnabled(el);
|
||||
conditionWebElement = webdriver.until.elementIsNotSelected(el);
|
||||
conditionWebElement = webdriver.until.elementIsNotVisible(el);
|
||||
conditionWebElement = webdriver.until.elementIsSelected(el);
|
||||
conditionWebElement = webdriver.until.elementIsVisible(el);
|
||||
conditionWebElement = webdriver.until.elementLocated(webdriver.By.id('id'));
|
||||
conditionWebElement = webdriver.until.elementTextContains(el, 'text');
|
||||
conditionWebElement = webdriver.until.elementTextIs(el, 'text');
|
||||
conditionWebElement = webdriver.until.elementTextMatches(el, /text/);
|
||||
conditionWebElements = webdriver.until.elementsLocated(webdriver.By.className('class'));
|
||||
}
|
||||
|
||||
function TestControlFlow() {
|
||||
let flow: webdriver.promise.ControlFlow;
|
||||
flow = new webdriver.promise.ControlFlow();
|
||||
|
||||
let emitter: webdriver.EventEmitter = flow;
|
||||
|
||||
let eventType: string;
|
||||
|
||||
eventType = webdriver.promise.ControlFlow.EventType.IDLE;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.RESET;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.SCHEDULE_TASK;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION;
|
||||
|
||||
let stringPromise: webdriver.promise.Promise<string>;
|
||||
stringPromise = flow.execute(() => 'value');
|
||||
stringPromise = flow.execute(() => stringPromise);
|
||||
stringPromise = flow.execute(() => stringPromise, 'Description');
|
||||
|
||||
let schedule: string;
|
||||
schedule = flow.toString();
|
||||
schedule = flow.getSchedule();
|
||||
schedule = flow.getSchedule(true);
|
||||
|
||||
flow.reset();
|
||||
|
||||
let voidPromise: webdriver.promise.Promise<void> = flow.timeout(123);
|
||||
voidPromise = flow.timeout(123, 'Description');
|
||||
|
||||
stringPromise = flow.wait(stringPromise);
|
||||
|
||||
voidPromise = flow.wait<void>(() => true);
|
||||
voidPromise = flow.wait<void>(() => true, 123);
|
||||
voidPromise = flow.wait<void>(() => stringPromise, 123, 'Timeout Message');
|
||||
}
|
||||
|
||||
function TestDeferred() {
|
||||
let deferred: webdriver.promise.Deferred<string>;
|
||||
|
||||
deferred = new webdriver.promise.Deferred<string>();
|
||||
deferred = new webdriver.promise.Deferred<string>(new webdriver.promise.ControlFlow());
|
||||
|
||||
let promise: webdriver.promise.Promise<string> = deferred.promise;
|
||||
|
||||
deferred.errback(new Error('Error'));
|
||||
deferred.errback('Error');
|
||||
deferred.fulfill('abc');
|
||||
deferred.reject(new Error('Error'));
|
||||
deferred.reject('Error');
|
||||
deferred.removeAll();
|
||||
}
|
||||
|
||||
declare const controlFlow: webdriver.promise.ControlFlow;
|
||||
|
||||
function TestPromiseClass() {
|
||||
let promise: webdriver.promise.Promise<string>;
|
||||
promise = new webdriver.promise.Promise<string>((resolve, reject) => {
|
||||
resolve("");
|
||||
resolve(Promise.resolve(""));
|
||||
reject(new Error());
|
||||
}, controlFlow);
|
||||
|
||||
promise = promise.then<string>();
|
||||
promise = promise.then((a: string) => 'cde');
|
||||
// tslint:disable-next-line void-return (need `--strictNullChecks` to change `void` to `undefined`)
|
||||
const promiseOrVoid: webdriver.promise.Promise<string | void> = promise.then((a: string) => 'cde', (e: any) => {});
|
||||
const promiseOrNumber: webdriver.promise.Promise<string | number> = promise.then((a: string) => 'cde', (e: any) => 123);
|
||||
}
|
||||
|
||||
function TestThenableClass() {
|
||||
// TODO: this doesn't test the Thenable class, it uses a Promise!
|
||||
let thenable: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>((resolve, reject) => {
|
||||
resolve('a');
|
||||
});
|
||||
|
||||
thenable = thenable.then((a: string) => 'cde');
|
||||
// tslint:disable-next-line void-return (need `--strictNullChecks` to change `void` to `undefined`)
|
||||
const thenableOrVoid: webdriver.promise.Promise<string | void> = thenable.then((a: string) => 'cde', (e: any) => {});
|
||||
const thenableOrNumber: webdriver.promise.Promise<string | number> = thenable.then((a: string) => 'cde', (e: any) => 123);
|
||||
}
|
||||
|
||||
async function TestAsyncAwaitable() {
|
||||
let thenable: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>((resolve, reject) => resolve('foo'));
|
||||
let str: string = await thenable;
|
||||
}
|
||||
|
||||
function TestPromiseManagerFlag() {
|
||||
webdriver.promise.USE_PROMISE_MANAGER = false;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as remote from "selenium-webdriver/remote";
|
||||
import * as webdriver from "selenium-webdriver";
|
||||
|
||||
function TestRemoteFileDetector() {
|
||||
const driver: webdriver.WebDriver = new webdriver.Builder()
|
||||
.withCapabilities(webdriver.Capabilities.chrome())
|
||||
.build();
|
||||
|
||||
const fileDetector: remote.FileDetector = new remote.FileDetector();
|
||||
fileDetector.handleFile(driver, 'path/to/file').then((path: string) => { /* empty */ });
|
||||
}
|
||||
|
||||
function TestSeleniumServer() {
|
||||
const pathToJar = '/path/to/jar';
|
||||
const seleniumServer: remote.SeleniumServer = new remote.SeleniumServer(pathToJar);
|
||||
}
|
||||
|
||||
function TestSeleniumServerOptions() {
|
||||
const pathToJar = '/path/to/jar';
|
||||
const options: remote.SeleniumServer.Options = {
|
||||
loopback: false,
|
||||
port: 4444,
|
||||
args: ['--testArg'],
|
||||
jvmArgs: ['--testJvmArg'],
|
||||
env: {test1: 'test1', test2: 'test2'},
|
||||
stdio: 'inherit'
|
||||
}
|
||||
const seleniumServer: remote.SeleniumServer = new remote.SeleniumServer(pathToJar, options);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": false,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"selenium-webdriver": [
|
||||
"selenium-webdriver/v3"
|
||||
],
|
||||
"selenium-webdriver/*": [
|
||||
"selenium-webdriver/v3/*"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"chrome.d.ts",
|
||||
"edge.d.ts",
|
||||
"firefox.d.ts",
|
||||
"http.d.ts",
|
||||
"ie.d.ts",
|
||||
"opera.d.ts",
|
||||
"remote.d.ts",
|
||||
"safari.d.ts",
|
||||
"testing.d.ts",
|
||||
"test/index.ts",
|
||||
"test/chrome.ts",
|
||||
"test/firefox.ts",
|
||||
"test/remote.ts",
|
||||
"test/testing.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODOs
|
||||
"align": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"interface-name": [false],
|
||||
"jsdoc-format": false,
|
||||
"no-empty-interface": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-any-union": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"prefer-const": false,
|
||||
"semicolon": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user