Moved a number of modules into their own files.

This commit is contained in:
Bill Armstrong
2014-12-13 01:25:40 -05:00
parent d09b8df795
commit c09fc5270f
6 changed files with 944 additions and 1098 deletions
+269
View File
@@ -0,0 +1,269 @@
declare module chrome {
/**
* Creates a new WebDriver client for Chrome.
*
* @extends {webdriver.WebDriver}
*/
class Driver extends webdriver.WebDriver {
/**
* @param {(webdriver.Capabilities|Options)=} opt_config The configuration
* options.
* @param {remote.DriverService=} opt_service The session to use; will use
* the {@link getDefaultService default service} by default.
* @param {webdriver.promise.ControlFlow=} opt_flow The control flow to use, or
* {@code null} to use the currently active flow.
* @constructor
*/
constructor(opt_config?: webdriver.Capabilities, opt_service?: any, opt_flow?: webdriver.promise.ControlFlow);
constructor(opt_config?: Options, opt_service?: any, opt_flow?: webdriver.promise.ControlFlow);
}
interface IOptionsValues {
args: string[];
binary?: string;
detach: boolean;
extensions: string[];
localState?: any;
logFile?: string;
prefs?: any;
}
/**
* Class for managing ChromeDriver specific options.
*/
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;
/**
* 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): 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 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 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 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;
/**
* Converts this instance to its JSON wire protocol representation. Note this
* function is an implementation not intended for general use.
* @return {{args: !Array.<string>,
* binary: (string|undefined),
* detach: boolean,
* extensions: !Array.<string>,
* localState: (Object|undefined),
* logFile: (string|undefined),
* prefs: (Object|undefined)}} The JSON wire protocol representation
* of this instance.
*/
toJSON(): IOptionsValues;
}
/**
* Creates {@link remote.DriverService} instances that manage a ChromeDriver
* server.
*/
class ServiceBuilder {
/**
* @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 the port to start the ChromeDriver on.
* @param {number} port The port to use, or 0 for any free port.
* @return {!ServiceBuilder} A self reference.
* @throws {Error} If the port is invalid.
*/
usingPort(port: number): ServiceBuilder;
/**
* 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): ServiceBuilder;
/**
* Enables verbose logging.
* @return {!ServiceBuilder} A self reference.
*/
enableVerboseLogging(): ServiceBuilder;
/**
* 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): ServiceBuilder;
/**
* Sets the base path for WebDriver REST commands (e.g. "/wd/hub").
* By default, the driver will accept commands relative to "/".
* @param {string} path The base path to use.
* @return {!ServiceBuilder} A self reference.
*/
setUrlBasePath(path: string): ServiceBuilder;
/**
* Defines the stdio configuration for the driver service. See
* {@code child_process.spawn} for more information.
* @param {(string|!Array.<string|number|!Stream|null|undefined>)} config The
* configuration to use.
* @return {!ServiceBuilder} A self reference.
*/
setStdio(config: string): ServiceBuilder;
setStdio(config: any[]): ServiceBuilder;
/**
* Defines the environment to start the server under. This settings will be
* inherited by every browser session started by the server.
* @param {!Object.<string, string>} env The environment to use.
* @return {!ServiceBuilder} A self reference.
*/
withEnvironment(env: { [key: string]: string }): ServiceBuilder;
/**
* Creates a new DriverService using this instance's current configuration.
* @return {remote.DriverService} A new driver service using this instance's
* current configuration.
* @throws {Error} If the driver exectuable was not specified and a default
* could not be found on the current PATH.
*/
build(): any;
}
/**
* 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.
*/
function getDefaultService(): any;
/**
* 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.
*/
function setDefaultService(service: any);
}
declare module 'selenium-webdriver/chrome' {
export = chrome;
}
+13
View File
@@ -0,0 +1,13 @@
declare module executors {
/**
* Creates a command executor that uses WebDriver's JSON wire protocol.
* @param url The server's URL, or a promise that will resolve to that URL.
* @returns {!webdriver.CommandExecutor} The new command executor.
*/
function createExecutor(url: string): webdriver.CommandExecutor;
function createExecutor(url: webdriver.promise.Promise<string>): webdriver.CommandExecutor;
}
declare module 'selenium-webdriver/executors' {
export = executors;
}
+238
View File
@@ -0,0 +1,238 @@
declare module firefox {
/**
* Manages a Firefox subprocess configured for use with WebDriver.
*/
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[]);
/**
* 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>;
}
/**
* A WebDriver client for Firefox.
*
* @extends {webdriver.WebDriver}
*/
class Driver extends webdriver.WebDriver {
/**
* @param {(Options|webdriver.Capabilities|Object)=} opt_config The
* configuration options for this driver, specified as either an
* {@link Options} or {@link webdriver.Capabilities}, or as a raw hash
* object.
* @param {webdriver.promise.ControlFlow=} opt_flow The flow to
* schedule commands through. Defaults to the active flow object.
* @constructor
*/
constructor(opt_config?: webdriver.Capabilities, opt_flow?: webdriver.promise.ControlFlow);
constructor(opt_config?: any, opt_flow?: webdriver.promise.ControlFlow);
}
/**
* Configuration options for the FirefoxDriver.
*/
class Options {
/**
* @constructor
*/
constructor();
/**
* 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;
setProfile(profile: Profile): 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): Options;
setBinary(binary: Binary): Options;
/**
* Sets the logging preferences for the new session.
* @param {webdriver.logging.Preferences} prefs The logging preferences.
* @return {!Options} A self reference.
*/
setLoggingPreferences(prefs: webdriver.logging.Preferences): Options;
/**
* Sets the proxy to use.
*
* @param {webdriver.ProxyConfig} proxy The proxy configuration to use.
* @return {!Options} A self reference.
*/
setProxy(proxy: webdriver.ProxyConfig): Options;
/**
* Converts these options to a {@link webdriver.Capabilities} instance.
*
* @return {!webdriver.Capabilities} A new capabilities object.
*/
toCapabilities(opt_remote?: any): webdriver.Capabilities;
}
/**
* Models a Firefox proifle directory for use with the FirefoxDriver. The
* {@code Proifle} directory uses an in-memory model until {@link #writeToDisk}
* is called.
*/
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);
/**
* 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);
setPreference(key: string, value: number);
setPreference(key: string, value: boolean);
/**
* 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);
/**
* @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);
/**
* Sets whether to assume untrusted certificates come from untrusted issuers.
* @param {boolean} value .
*/
setAssumeUntrustedCertIssuer(value: boolean);
/**
* @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);
/**
* 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>;
}
}
declare module 'selenium-webdriver/firefox' {
export = firefox;
}
+199 -224
View File
@@ -1,28 +1,29 @@
/// <reference path="selenium-webdriver.d.ts" />
function TestAbstractBuilder() {
var builder: webdriver.AbstractBuilder = new webdriver.AbstractBuilder();
var driver: webdriver.WebDriver = builder.build();
var capabilities: webdriver.Capabilities = builder.getCapabilities();
url = builder.getServerUrl();
var otherBuilder: webdriver.AbstractBuilder = builder.usingServer(url);
otherBuilder = builder.withCapabilities(webdriver.Capabilities.android());
var objCapabilities: { [index: string]: string; } = {};
objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.PHANTOM_JS;
otherBuilder = builder.withCapabilities(objCapabilities);
var url: string = webdriver.AbstractBuilder.DEFAULT_SERVER_URL;
var env: string = webdriver.AbstractBuilder.SERVER_URL_ENV;
}
/// <reference path="executors.d.ts" />
function TestBuilder() {
var builder: webdriver.Builder = new webdriver.Builder();
var abstractBuilder: webdriver.AbstractBuilder = builder;
var driver: webdriver.WebDriver = builder.build();
var session: string = builder.getSession();
abstractBuilder = builder.usingSession("ID");
builder = builder.forBrowser('name');
builder = builder.forBrowser('name', 'version');
builder = builder.forBrowser('name', 'version', 'platform');
var env: string = webdriver.Builder.SESSION_ID_ENV;
var cap: webdriver.Capabilities = builder.getCapabilities();
var str:string = builder.getServerUrl();
builder = builder.setAlertBehavior('behavior');
builder = builder.setChromeOptions(new chrome.Options());
builder = builder.setControlFlow(new webdriver.promise.ControlFlow());
builder = builder.setEnableNativeEvents(true);
builder = builder.setFirefoxOptions(new firefox.Options());
builder = builder.setLoggingPrefs(new webdriver.logging.Preferences());
builder = builder.setLoggingPrefs({ "key": "value" });
builder = builder.setProxy({ proxyType: 'type' });
builder = builder.setScrollBehavior(1);
builder = builder.usingServer('http://someserver');
builder = builder.withCapabilities(new webdriver.Capabilities());
builder = builder.withCapabilities({ something: true });
}
function TestActionSequence() {
@@ -31,7 +32,7 @@ function TestActionSequence() {
build();
var sequence: webdriver.ActionSequence = new webdriver.ActionSequence(driver);
var element: webdriver.WebElement = new webdriver.WebElement(driver, 'id');
var element: webdriver.WebElement = new webdriver.WebElement(driver, { ELEMENT: 'id' });
// Click
sequence = sequence.click();
@@ -76,23 +77,20 @@ function TestActionSequence() {
sequence = sequence.sendKeys("A", "B", "C");
sequence = sequence.sendKeys(["A", "B", "C"]);
var promise: webdriver.promise.Promise = sequence.perform();
sequence.perform().then(function () { });
}
function TestAlert() {
var driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
var promise: webdriver.promise.Promise = new webdriver.promise.Promise();
var alert: webdriver.Alert = new webdriver.Alert(driver, 'ABC');
alert = new webdriver.Alert(driver, promise);
var deferred: webdriver.promise.Deferred = alert;
var alert: webdriver.Alert = driver.switchTo().alert();
promise = alert.accept();
promise = alert.dismiss();
promise = alert.getText();
promise = alert.sendKeys("ABC");
alert.accept().then(function () { });
alert.dismiss().then(function () { });
alert.getText().then(function (text: string) { });
alert.sendKeys("ABC").then(function () { });
}
function TestBrowser() {
@@ -131,6 +129,12 @@ function TestCapabilities() {
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();
@@ -152,14 +156,15 @@ function TestCapability() {
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_BROWSER_CONNECTION;
capability = webdriver.Capability.SUPPORTS_CSS_SELECTORS;
capability = webdriver.Capability.SUPPORTS_JAVASCRIPT;
capability = webdriver.Capability.SUPPORTS_LOCATION_CONTEXT;
@@ -181,7 +186,8 @@ function TestCommand() {
}
function TestCommandExecutor() {
var c: webdriver.CommandExecutor = { execute: function(command: webdriver.Command, callback: (error: Error, obj: any) => any) {} };
var c: webdriver.CommandExecutor = { execute: function (command: webdriver.Command, callback: (error: Error, obj: any) => any) { } };
c.execute(new webdriver.Command('name'), function (error: Error, response: any) { });
}
function TestCommandName() {
@@ -291,10 +297,14 @@ function TestEventEmitter() {
var callback = function (a: number, b: number, c: number) {};
emitter = emitter.addListener('ABC', callback);
emitter = emitter.addListener('ABC', callback, this);
emitter.emit('ABC', 1, 2, 3);
var listeners = emitter.listeners('ABC');
if (listeners[0].oneshot) {
listeners[0].fn.apply(listeners[0].scope);
}
var length: number = listeners.length;
var listenerInfo = listeners[0];
if (listenerInfo.oneshot) {
@@ -302,8 +312,10 @@ function TestEventEmitter() {
}
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);
@@ -311,14 +323,6 @@ function TestEventEmitter() {
emitter.removeAllListeners();
}
function TestFirefoxDomExecutor() {
if (webdriver.FirefoxDomExecutor.isAvailable()) {
var executor: webdriver.CommandExecutor = new webdriver.FirefoxDomExecutor();
var callback = function(error: Error, responseObject: any) {};
executor.execute(new webdriver.Command(webdriver.CommandName.CLICK), callback);
}
}
function TestKey() {
var key: string;
@@ -387,21 +391,28 @@ function TestKey() {
}
function TestLocator() {
var locator: webdriver.Locator = new webdriver.Locator('id', 'ABC');
var driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
var locator: webdriver.Locator = webdriver.By.className('class');
var locatorStr: string = locator.toString();
var using: string = locator.using;
var value: string = locator.value;
locator = webdriver.Locator.checkLocator(webdriver.Locator.Strategy.id('ABC'));
locator = webdriver.Locator.checkLocator({id: 'ABC'});
var str: string = locator.toString();
locator = webdriver.Locator.createFromObj({id: 'ABC'});
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');
locator = webdriver.Locator.Strategy.id('ABC');
locator = webdriver.By.id('ABC');
webdriver.By.js('script', 1, 2, 3)(driver).then(function (abc: number) { });
}
function TestSession() {
@@ -418,16 +429,13 @@ function TestSession() {
}
function TestUnhandledAlertError() {
var driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
var promise: webdriver.promise.Promise = new webdriver.promise.Promise();
var someFunc = function (error: webdriver.UnhandledAlertError) {
var baseError: webdriver.error.Error = error;
var alert: webdriver.Alert = new webdriver.Alert(driver, 'ABC');
var error = new webdriver.UnhandledAlertError('An error', alert);
var baseError: webdriver.error.Error = error;
alert = error.getAlert();
var alert: webdriver.Alert = error.getAlert();
var str: string = error.getAlertText();
str = error.toString();
}
}
function TestWebDriverLogs() {
@@ -435,11 +443,10 @@ function TestWebDriverLogs() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
var logs: webdriver.WebDriverLogs = webdriver.WebDriver.Logs;
var promise: webdriver.promise.Promise;
var logs: webdriver.WebDriverLogs = new webdriver.WebDriver.Logs(driver);
promise = logs.get(webdriver.logging.Type.BROWSER);
promise = logs.getAvailableLogTypes();
logs.get(webdriver.logging.Type.BROWSER).then(function (entries: webdriver.logging.Entry[]) { });;
logs.getAvailableLogTypes().then(function (types: string[]) { });
}
function TestWebDriverNavigation() {
@@ -447,13 +454,12 @@ function TestWebDriverNavigation() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
var navigation: webdriver.WebDriverNavigation = webdriver.WebDriver.Navigation;
var promise: webdriver.promise.Promise;
var navigation: webdriver.WebDriverNavigation = new webdriver.WebDriver.Navigation(driver);
promise = navigation.back();
promise = navigation.forward();
promise = navigation.refresh();
promise = navigation.to('http://google.com');
navigation.back().then(function () { });
navigation.forward().then(function () { });
navigation.refresh().then(function () { });
navigation.to('http://google.com').then(function () { });
}
function TestWebDriverOptions() {
@@ -461,8 +467,8 @@ function TestWebDriverOptions() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
var options: webdriver.WebDriverOptions = webdriver.WebDriver.Options;
var promise: webdriver.promise.Promise;
var options: webdriver.WebDriverOptions = new webdriver.WebDriver.Options(driver);
var promise: webdriver.promise.Promise<void>;
// Add Cookie
promise = options.addCookie('name', 'value');
@@ -474,8 +480,8 @@ function TestWebDriverOptions() {
promise = options.deleteAllCookies();
promise = options.deleteCookie('name');
promise = options.getCookie('name');
promise = options.getCookies();
options.getCookie('name').then(function (cookies: webdriver.IWebDriverOptionsCookie) { });
options.getCookies().then(function (cookies: webdriver.IWebDriverOptionsCookie[]) { });
var logs: webdriver.WebDriverLogs = options.logs();
var timeouts: webdriver.WebDriverTimeouts = options.timeouts();
@@ -487,8 +493,8 @@ function TestWebDriverTargetLocator() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
var locator: webdriver.WebDriverTargetLocator = webdriver.WebDriver.TargetLocator;
var promise: webdriver.promise.Promise;
var locator: webdriver.WebDriverTargetLocator = new webdriver.WebDriver.TargetLocator(driver);
var promise: webdriver.promise.Promise<void>;
var element: webdriver.WebElement = locator.activeElement();
var alert: webdriver.Alert = locator.alert();
@@ -503,8 +509,8 @@ function TestWebDriverTimeouts() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
var timeouts: webdriver.WebDriverTimeouts = webdriver.WebDriver.Timeouts;
var promise: webdriver.promise.Promise;
var timeouts: webdriver.WebDriverTimeouts = new webdriver.WebDriver.Timeouts(driver);
var promise: webdriver.promise.Promise<void>;
promise = timeouts.implicitlyWait(123);
promise = timeouts.pageLoadTimeout(123);
@@ -516,46 +522,52 @@ function TestWebDriverWindow() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
var window: webdriver.WebDriverWindow = webdriver.WebDriver.Window;
var promise: webdriver.promise.Promise;
var window: webdriver.WebDriverWindow = new webdriver.WebDriver.Window(driver);
var locationPromise: webdriver.promise.Promise<webdriver.ILocation>;
var sizePromise: webdriver.promise.Promise<webdriver.ISize>;
var voidPromise: webdriver.promise.Promise<void>;
promise = window.getPosition();
promise = window.getSize();
promise = window.maximize();
promise = window.setPosition(12, 34);
promise = window.setSize(12, 34);
locationPromise = window.getPosition();
sizePromise = window.getSize();
voidPromise = window.maximize();
voidPromise = window.setPosition(12, 34);
voidPromise = window.setSize(12, 34);
}
function TestWebDriver() {
var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
var promise: webdriver.promise.Promise = new webdriver.promise.Promise();
var executor: webdriver.CommandExecutor = new webdriver.FirefoxDomExecutor();
var sessionPromise: webdriver.promise.Promise<webdriver.Session> = new webdriver.promise.Promise<webdriver.Session>();
var executor: webdriver.CommandExecutor = executors.createExecutor("http://someserver");
var flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow();
var driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor);
driver = new webdriver.WebDriver(session, executor, flow);
driver = new webdriver.WebDriver(promise, executor);
driver = new webdriver.WebDriver(promise, executor, flow);
driver = new webdriver.WebDriver(sessionPromise, executor);
driver = new webdriver.WebDriver(sessionPromise, executor, flow);
var voidPromise: webdriver.promise.Promise<void>;
var stringPromise: webdriver.promise.Promise<string>;
var booleanPromise: webdriver.promise.Promise<boolean>;
// Call
var actions: webdriver.ActionSequence = driver.actions();
promise = driver.call(function(){});
promise = driver.call(function(){ var d: any = this;}, driver);
promise = driver.call(function(a: number){}, driver, 1);
stringPromise = driver.call<string>(function(){});
stringPromise = driver.call<string>(function(){ var d: any = this;}, driver);
stringPromise = driver.call<string>(function(a: number){}, driver, 1);
promise = driver.close();
voidPromise = driver.close();
flow = driver.controlFlow();
// ExecuteAsyncScript
promise = driver.executeAsyncScript('function(){}');
promise = driver.executeAsyncScript('function(){}', 1, 2, 3);
promise = driver.executeAsyncScript(function(){});
promise = driver.executeAsyncScript(function(a: number){}, 1);
stringPromise = driver.executeAsyncScript<string>('function(){}');
stringPromise = driver.executeAsyncScript<string>('function(){}', 1, 2, 3);
stringPromise = driver.executeAsyncScript<string>(function(){});
stringPromise = driver.executeAsyncScript<string>(function(a: number){}, 1);
// ExecuteScript
promise = driver.executeScript('function(){}');
promise = driver.executeScript('function(){}', 1, 2, 3);
promise = driver.executeScript(function(){});
promise = driver.executeScript(function(a: number){}, 1);
stringPromise = driver.executeScript<string>('function(){}');
stringPromise = driver.executeScript<string>('function(){}', 1, 2, 3);
stringPromise = driver.executeScript<string>(function(){});
stringPromise = driver.executeScript<string>(function(a: number){}, 1);
var element: webdriver.WebElement;
element = driver.findElement(webdriver.By.id('ABC'));
@@ -563,38 +575,36 @@ function TestWebDriver() {
element = driver.findElement(webdriver.By.js('function(){}'), 1, 2, 3);
element = driver.findElement({js: 'function(){}'}, 1, 2, 3);
promise = driver.findElements(webdriver.By.className('ABC'));
promise = driver.findElements({className: 'ABC'});
promise = driver.findElements(webdriver.By.js('function(){}'), 1, 2, 3);
promise = driver.findElements({js: 'function(){}'}, 1, 2, 3);
driver.findElements(webdriver.By.className('ABC')).then(function (elements: webdriver.WebElement[]) { });
driver.findElements({ className: 'ABC' }).then(function (elements: webdriver.WebElement[]) { });
driver.findElements(webdriver.By.js('function(){}'), 1, 2, 3).then(function (elements: webdriver.WebElement[]) { });
driver.findElements({ js: 'function(){}' }, 1, 2, 3).then(function (elements: webdriver.WebElement[]) { });
promise = driver.get('http://www.google.com');
promise = driver.getAllWindowHandles();
promise = driver.getCapabilities();
promise = driver.getCurrentUrl();
promise = driver.getPageSource()
promise = driver.getSession();
promise = driver.getTitle();
promise = driver.getWindowHandle();
voidPromise = driver.get('http://www.google.com');
driver.getAllWindowHandles().then(function (handles: string[]) { });
driver.getCapabilities().then(function (caps: webdriver.Capabilities) { });
stringPromise = driver.getCurrentUrl();
stringPromise = driver.getPageSource()
driver.getSession().then(function (session: webdriver.Session) { });;
stringPromise = driver.getTitle();
stringPromise = driver.getWindowHandle();
promise = driver.isElementPresent(webdriver.By.className('ABC'));
promise = driver.isElementPresent({className: 'ABC'});
promise = driver.isElementPresent(webdriver.By.js('function(){}'), 1, 2, 3);
promise = driver.isElementPresent({js: 'function(){}'}, 1, 2, 3);
booleanPromise = driver.isElementPresent(webdriver.By.className('ABC'));
booleanPromise = driver.isElementPresent({className: 'ABC'});
booleanPromise = driver.isElementPresent(webdriver.By.js('function(){}'), 1, 2, 3);
booleanPromise = driver.isElementPresent({js: 'function(){}'}, 1, 2, 3);
var options: webdriver.WebDriverOptions = driver.manage();
var navigation: webdriver.WebDriverNavigation = driver.navigate();
var locator: webdriver.WebDriverTargetLocator = driver.switchTo();
promise = driver.quit();
promise = driver.schedule(new webdriver.Command(webdriver.CommandName.CLICK), 'ABC');
promise = driver.sleep(123);
promise = driver.takeScreenshot();
voidPromise = driver.quit();
voidPromise = driver.schedule<void>(new webdriver.Command(webdriver.CommandName.CLICK), 'ABC');
voidPromise = driver.sleep(123);
stringPromise = driver.takeScreenshot();
promise = driver.wait(function() { return true; }, 123);
promise = driver.wait(function() { return true; }, 123, 'Message');
promise = driver.wait(function() { return promise; }, 123);
promise = driver.wait(function() { return promise; }, 123, 'Message');
booleanPromise = driver.wait(function() { return true; }, 123);
booleanPromise = driver.wait(function() { return true; }, 123, 'Message');
driver = webdriver.WebDriver.attachToSession(executor, 'ABC');
driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android());
@@ -606,55 +616,50 @@ function TestWebElement() {
build();
var element: webdriver.WebElement;
var promise: webdriver.promise.Promise = new webdriver.promise.Promise();
element = new webdriver.WebElement(driver, 'ID');
element = new webdriver.WebElement(driver, promise);
element = new webdriver.WebElement(driver, { ELEMENT: 'ID' });
element = new webdriver.WebElement(driver, new webdriver.promise.Promise<webdriver.IWebElementId>());
var deferred: webdriver.promise.Deferred = element;
var voidPromise: webdriver.promise.Promise<void>;
var stringPromise: webdriver.promise.Promise<string>;
var booleanPromise: webdriver.promise.Promise<boolean>;
promise = element.clear();
promise = element.click();
voidPromise = element.clear();
voidPromise = element.click();
element = element.findElement(webdriver.By.id('ABC'));
element = element.findElement({id: 'ABC'});
element = element.findElement(webdriver.By.js('function(){}'), 1, 2, 3);
element = element.findElement({js: 'function(){}'}, 1, 2, 3);
promise = element.findElements(webdriver.By.className('ABC'));
promise = element.findElements({className: 'ABC'});
promise = element.findElements(webdriver.By.js('function(){}'), 1, 2, 3);
promise = element.findElements({js: 'function(){}'}, 1, 2, 3);
element.findElements(webdriver.By.className('ABC')).then(function (elements: webdriver.WebElement[]) { });
element.findElements({ className: 'ABC' }).then(function (elements: webdriver.WebElement[]) { });
promise = element.isElementPresent(webdriver.By.className('ABC'));
promise = element.isElementPresent({className: 'ABC'});
promise = element.isElementPresent(webdriver.By.js('function(){}'), 1, 2, 3);
promise = element.isElementPresent({js: 'function(){}'}, 1, 2, 3);
booleanPromise = element.isElementPresent(webdriver.By.className('ABC'));
booleanPromise = element.isElementPresent({className: 'ABC'});
promise = element.getAttribute('class');
promise = element.getCssValue('display');
stringPromise = element.getAttribute('class');
stringPromise = element.getCssValue('display');
driver = element.getDriver();
promise = element.getInnerHtml();
promise = element.getLocation();
promise = element.getOuterHtml();
promise = element.getSize();
promise = element.getTagName();
promise = element.getText();
promise = element.isDisplayed();
promise = element.isEnabled();
promise = element.isSelected();
promise = element.sendKeys('A', 'B', 'C');
promise = element.submit();
promise = element.toWireValue();
stringPromise = element.getInnerHtml();
element.getLocation().then(function (location: webdriver.ILocation) { });
stringPromise = element.getOuterHtml();
element.getSize().then(function (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.submit();
element.getId().then(function (id: webdriver.IWebElementId) { });
promise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, 'ID2'));
booleanPromise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, { ELEMENT: 'ID2' }));
var key: string = webdriver.WebElement.ELEMENT_KEY;
}
function TestLogging() {
webdriver.logging.Preferences['name'] = 'ABC';
var level: webdriver.logging.Level = webdriver.logging.getLevel('OFF');
var level: webdriver.logging.ILevel = webdriver.logging.getLevel('OFF');
level = webdriver.logging.getLevel(1);
level = webdriver.logging.Level.ALL;
@@ -667,13 +672,6 @@ function TestLogging() {
var name: string = level.name;
var value: number = level.value;
name = webdriver.logging.LevelName.ALL;
name = webdriver.logging.LevelName.DEBUG;
name = webdriver.logging.LevelName.INFO;
name = webdriver.logging.LevelName.OFF;
name = webdriver.logging.LevelName.SEVERE;
name = webdriver.logging.LevelName.WARNING;
var type: string;
type = webdriver.logging.Type.BROWSER;
type = webdriver.logging.Type.CLIENT;
@@ -702,47 +700,44 @@ function TestLoggingEntry() {
entry = webdriver.logging.Entry.fromClosureLogRecord({}, webdriver.logging.Type.DRIVER);
}
function TestProcess() {
var isNative: boolean = webdriver.process.isNative();
var value: string;
function TestPromiseNamespace() {
var stringPromise: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>();
var numberPromise: webdriver.promise.Promise<number>;
var booleanPromise: webdriver.promise.Promise<boolean>;
var voidPromise: webdriver.promise.Promise<void>;
value = webdriver.process.getEnv('name');
value = webdriver.process.getEnv('name', 'default');
webdriver.promise.asap('abc', function(value: any){ return true; });
webdriver.promise.asap('abc', function(value: any){}, function(err: any) { return 'ABC'; });
webdriver.process.setEnv('name', 'value');
webdriver.process.setEnv('name', 123);
}
function TestPromise() {
var promise: webdriver.promise.Promise = new webdriver.promise.Promise();
webdriver.promise.asap(promise, function(value: any){ return true; });
webdriver.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
promise = webdriver.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
stringPromise = webdriver.promise.checkedNodeCall<string>(function(err: any, value: any) { return 'abc'; });
var flow: webdriver.promise.ControlFlow = webdriver.promise.controlFlow();
promise = webdriver.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
stringPromise = webdriver.promise.createFlow<string>(function(newFlow: webdriver.promise.ControlFlow) { return 'ABC' });
var deferred: webdriver.promise.Deferred;
deferred = webdriver.promise.defer(function() {});
deferred = webdriver.promise.defer(function(reason?: any) {});
var deferred: webdriver.promise.Deferred<string>;
deferred = webdriver.promise.defer();
deferred = webdriver.promise.defer();
promise = webdriver.promise.delayed(123);
stringPromise = deferred.promise;
promise = webdriver.promise.fulfilled();
promise = webdriver.promise.fulfilled({a: 123});
deferred.fulfill('ABC');
deferred.reject('error');
promise = webdriver.promise.fullyResolved({a: 123});
voidPromise = webdriver.promise.delayed(123);
voidPromise = webdriver.promise.fulfilled<void>();
stringPromise = webdriver.promise.fulfilled('abc');
stringPromise = webdriver.promise.fullyResolved('abc');
var isPromise: boolean = webdriver.promise.isPromise('ABC');
promise = webdriver.promise.rejected({a: 123});
voidPromise = webdriver.promise.rejected({a: 123});
webdriver.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
promise = webdriver.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
numberPromise = webdriver.promise.when('abc', function(value: any) { return 123; }, function(err: Error) { return 123; });
}
function TestControlFlow() {
@@ -763,14 +758,14 @@ function TestControlFlow() {
var e: any = flow.annotateError(new Error('Error'));
var promise: webdriver.promise.Promise;
var stringPromise: webdriver.promise.Promise<string>;
promise = flow.await(promise);
stringPromise = flow.await(stringPromise);
flow.clearHistory();
promise = flow.execute(function() { return promise; });
promise = flow.execute(function() { return promise; }, 'Description');
stringPromise = flow.execute(function() { return stringPromise; });
stringPromise = flow.execute(function() { return stringPromise; }, 'Description');
var history: string[] = flow.getHistory();
@@ -778,12 +773,12 @@ function TestControlFlow() {
flow.reset();
promise = flow.timeout(123);
promise = flow.timeout(123, 'Description');
var voidPromise: webdriver.promise.Promise<void> = flow.timeout(123);
voidPromise = flow.timeout(123, 'Description');
promise = flow.wait(function() { return true; }, 123);
promise = flow.wait(function() { return true; }, 123, 'Timeout Message');
promise = flow.wait(function() { return promise; }, 123, 'Timeout Message');
voidPromise = flow.wait(function() { return true; }, 123);
voidPromise = flow.wait(function() { return true; }, 123, 'Timeout Message');
voidPromise = flow.wait(function() { return stringPromise; }, 123, 'Timeout Message');
var timer: webdriver.promise.IControlFlowTimer = flow.timer;
@@ -792,53 +787,33 @@ function TestControlFlow() {
}
function TestDeferred() {
var deferred: webdriver.promise.Deferred;
var deferred: webdriver.promise.Deferred<string>;
deferred = new webdriver.promise.Deferred();
deferred = new webdriver.promise.Deferred(function() {});
deferred = new webdriver.promise.Deferred(function(reason: any) { });
deferred = new webdriver.promise.Deferred(function() {}, new webdriver.promise.ControlFlow());
deferred = new webdriver.promise.Deferred<string>();
deferred = new webdriver.promise.Deferred<string>(new webdriver.promise.ControlFlow());
var promise: webdriver.promise.Promise = deferred;
var promise: webdriver.promise.Promise<string> = deferred.promise;
deferred.errback(new Error('Error'));
deferred.errback('Error');
deferred.fulfill(123);
deferred.fulfill('abc');
deferred.reject(new Error('Error'));
deferred.reject('Error');
deferred.removeAll();
promise = deferred.promise;
}
function TestPromiseClass() {
var promise: webdriver.promise.Promise = new webdriver.promise.Promise();
var promise: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>();
var obj = {
a: 5
}
promise = promise.addBoth(function( a: any ) { });
promise = promise.addBoth(function( a: any ) { return 123; });
promise = promise.addBoth(function( a: any ) { }, obj);
promise = promise.addCallback(function( a: any ) { });
promise = promise.addCallback(function( a: any ) { return 123; });
promise = promise.addCallback(function( a: any ) { }, obj);
promise = promise.addErrback(function( e: any ) { });
promise = promise.addErrback(function( e: any ) { return 123; });
promise = promise.addErrback(function( e: any ) { }, obj);
promise.cancel(obj);
promise.cancel('Abort');
var isPending: boolean = promise.isPending();
promise = promise.then();
promise = promise.then(function( a: any ) { });
promise = promise.then(function( a: any ) { return 123; });
promise = promise.then(function( a: any ) {}, function( e: any) {});
promise = promise.then(function( a: any ) {}, function( e: any) { return 123; });
promise = promise.then(function( a: string ) { });
promise = promise.then(function( a: string ) { return 'cde'; });
promise = promise.then(function( a: string ) {}, function( e: any) {});
promise = promise.then(function( a: string ) {}, function( e: any) { return 123; });
}
function TestErrorCode() {
File diff suppressed because it is too large Load Diff
+62
View File
@@ -0,0 +1,62 @@
declare module 'selenium-webdriver/testing' {
/**
* Registers a new test suite.
* @param name The suite name.
* @param fn The suite function, or {@code undefined} to define a pending test suite.
*/
function describe(name: string, fn: Function): void;
/**
* Defines a suppressed test suite.
* @param name The suite name.
* @param fn The suite function, or {@code undefined} to define a pending test suite.
*/
function xdescribe(name: string, fn: Function): void;
/**
* Register a function to call after the current suite finishes.
* @param fn
*/
function after(fn: Function): void;
/**
* Register a function to call after each test in a suite.
* @param fn
*/
function afterEach(fn: Function): void;
/**
* Register a function to call before the current suite starts.
* @param fn
*/
function before(fn: Function): void;
/**
* Register a function to call before each test in a suite.
* @param fn
*/
function beforeEach(fn: Function): void;
/**
* Add a test to the current suite.
* @param name The test name.
* @param fn The test function, or {@code undefined} to define a pending test case.
*/
function it(name: string, fn: Function): void;
/**
* An alias for {@link #it()} that flags the test as the only one that should
* be run within the current suite.
* @param name The test name.
* @param fn The test function, or {@code undefined} to define a pending test case.
*/
function iit(name: string, fn: Function): void;
/**
* Adds a test to the current suite while suppressing it so it is not run.
* @param name The test name.
* @param fn The test function, or {@code undefined} to define a pending test case.
*/
function xit(name: string, fn: Function): void;
}