mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-07 09:49:07 +00:00
Merged all of the selenium webdriver .ts files.
The CI build was failing because it tries to compile each file individually. To fix this I merged all of the files into one. I also deleted the legacy files since those versions are no longer supported.
This commit is contained in:
@@ -1,244 +0,0 @@
|
||||
/// <reference path="angular-protractor-0.17.0.d.ts" />
|
||||
|
||||
function TestWebDriverExports() {
|
||||
var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
|
||||
var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
|
||||
|
||||
var button: protractor.Button = new protractor.Button();
|
||||
var baseButton: webdriver.Button = button;
|
||||
|
||||
var key: string = protractor.Key.ADD;
|
||||
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
|
||||
|
||||
var driver: protractor.WebDriver = new protractor.Builder().
|
||||
withCapabilities(protractor.Capabilities.chrome()).
|
||||
build();
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
|
||||
var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
|
||||
var baseAction: webdriver.ActionSequence = action;
|
||||
|
||||
var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
|
||||
var baseAlert: webdriver.Alert = alert;
|
||||
|
||||
var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
|
||||
var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
|
||||
|
||||
var browser: string = protractor.Browser.ANDROID;
|
||||
|
||||
var builder: protractor.Builder = new protractor.Builder();
|
||||
var baseBuilder: webdriver.Builder = builder;
|
||||
|
||||
var capability: string = protractor.Capability.BROWSER_NAME;
|
||||
|
||||
var capabilities: protractor.Capabilities = protractor.Capabilities.chrome();
|
||||
var baseCapabilities: webdriver.Capabilities = capabilities;
|
||||
|
||||
var commandName: string = protractor.CommandName.CLICK_ELEMENT;
|
||||
|
||||
var command: protractor.Command = new protractor.Command(protractor.CommandName.CLICK);
|
||||
var baseCommand: webdriver.Command = command;
|
||||
|
||||
var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
|
||||
var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
|
||||
|
||||
var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
|
||||
var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
|
||||
|
||||
var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
|
||||
var baseWebElement: webdriver.WebElement = webElement;
|
||||
|
||||
var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
|
||||
var baseLocator: webdriver.Locator = locator;
|
||||
|
||||
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
|
||||
var baseSession: webdriver.Session = session;
|
||||
|
||||
locator = protractor.By.name('name');
|
||||
|
||||
// logging module
|
||||
|
||||
var levelName: string = protractor.logging.LevelName.ALL;
|
||||
var loggingType: string = protractor.logging.Type.CLIENT;
|
||||
|
||||
var level: webdriver.logging.Level = protractor.logging.Level.ALL;
|
||||
|
||||
var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
|
||||
var baseEntry: webdriver.logging.Entry = entry;
|
||||
|
||||
level = protractor.logging.getLevel('DEBUG');
|
||||
|
||||
protractor.logging.Preferences = { a: 123 };
|
||||
|
||||
// promise module
|
||||
|
||||
var promise: protractor.promise.Promise = new protractor.promise.Promise();
|
||||
var basePromise: webdriver.promise.Promise = promise;
|
||||
|
||||
var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
|
||||
var baseDeferred: webdriver.promise.Deferred = deferred;
|
||||
|
||||
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
|
||||
var baseFlow: webdriver.promise.ControlFlow = flow;
|
||||
|
||||
protractor.promise.asap(promise, function(value: any){ return true; });
|
||||
protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
|
||||
|
||||
promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
|
||||
|
||||
flow = protractor.promise.controlFlow();
|
||||
|
||||
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
|
||||
|
||||
deferred = protractor.promise.defer(function() {});
|
||||
deferred = protractor.promise.defer(function(reason?: any) {});
|
||||
|
||||
promise = protractor.promise.delayed(123);
|
||||
|
||||
promise = protractor.promise.fulfilled();
|
||||
promise = protractor.promise.fulfilled({a: 123});
|
||||
|
||||
promise = protractor.promise.fullyResolved({a: 123});
|
||||
|
||||
var isPromise: boolean = protractor.promise.isPromise('ABC');
|
||||
|
||||
promise = protractor.promise.rejected({a: 123});
|
||||
|
||||
protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
|
||||
|
||||
promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
|
||||
|
||||
// error module
|
||||
|
||||
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
|
||||
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
|
||||
// process module
|
||||
|
||||
var isNative: boolean = protractor.process.isNative();
|
||||
var value: string;
|
||||
|
||||
value = protractor.process.getEnv('name');
|
||||
value = protractor.process.getEnv('name', 'default');
|
||||
|
||||
protractor.process.setEnv('name', 'value');
|
||||
protractor.process.setEnv('name', 123);
|
||||
|
||||
}
|
||||
|
||||
function TestProtractor() {
|
||||
var ptor: protractor.Protractor;
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
ptor = new protractor.Protractor(driver);
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl');
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
|
||||
ptor = protractor.getInstance();
|
||||
protractor.setInstance(ptor);
|
||||
|
||||
ptor = protractor.wrapDriver(driver);
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl');
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
|
||||
|
||||
ptor = browser;
|
||||
|
||||
driver = ptor.driver;
|
||||
var baseUrl: string = ptor.baseUrl;
|
||||
var rootEl: string = ptor.rootEl;
|
||||
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
|
||||
var params: any = ptor.params;
|
||||
|
||||
ptor.debugger();
|
||||
|
||||
ptor.clearMockModules();
|
||||
ptor.addMockModule('name', 'script');
|
||||
ptor.addMockModule('name', function() {});
|
||||
ptor.waitForAngular();
|
||||
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
|
||||
elementFinder = ptor.element(by.id('ABC'));
|
||||
elementFinder = ptor.$('.class');
|
||||
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id'));
|
||||
|
||||
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
|
||||
}
|
||||
|
||||
function TestElement() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.className('class'));
|
||||
}
|
||||
|
||||
function TestElementFinder() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = elementFinder.click();
|
||||
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
promise = elementFinder.getTagName();
|
||||
promise = elementFinder.getCssValue('display');
|
||||
promise = elementFinder.getAttribute('atribute');
|
||||
promise = elementFinder.getText();
|
||||
promise = elementFinder.getSize();
|
||||
promise = elementFinder.getLocation();
|
||||
promise = elementFinder.isEnabled();
|
||||
promise = elementFinder.isSelected();
|
||||
promise = elementFinder.submit();
|
||||
promise = elementFinder.clear();
|
||||
promise = elementFinder.isDisplayed();
|
||||
promise = elementFinder.getOuterHtml();
|
||||
promise = elementFinder.getInnerHtml();
|
||||
promise = elementFinder.isElementPresent(by.id('id'));
|
||||
promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.findElements(by.className('class'));
|
||||
promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.$$('.class');
|
||||
promise = elementFinder.evaluate('expression');
|
||||
promise = elementFinder.isPresent();
|
||||
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
webElement = elementFinder.$('.class');
|
||||
webElement = elementFinder.findElement(by.id('id'));
|
||||
webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
webElement = elementFinder.find();
|
||||
}
|
||||
|
||||
// This function tests the angular specific locator strategies.
|
||||
function TestLocatorStrategies() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
// Protractor Specific Locators
|
||||
webElement = ptor.findElement(protractor.By.binding('binding'));
|
||||
webElement = ptor.findElement(protractor.By.select('select'));
|
||||
webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions'));
|
||||
webElement = ptor.findElement(protractor.By.input('input'));
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
webElement = ptor.findElement(protractor.By.textarea('textarea'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater'));
|
||||
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
}
|
||||
|
||||
// This function tests the methods that were added to the base WebElement class
|
||||
function TestWebElements() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
|
||||
var webElement: protractor.WebElement;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
webElement = ptor.findElement(by.id('id')).$('.class');
|
||||
promise = ptor.findElement(by.id('id')).$$('.class');
|
||||
promise = ptor.findElement(by.id('id')).evaluate('something');
|
||||
|
||||
webElement = webElement.findElement(by.id('id')).$('.class');
|
||||
promise = webElement.findElement(by.id('id')).$$('.class');
|
||||
promise = webElement.findElement(by.id('id')).evaluate('something');
|
||||
}
|
||||
@@ -1,906 +0,0 @@
|
||||
// Type definitions for Angular Protractor 0.17.0
|
||||
// Project: https://github.com/angular/protractor
|
||||
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../../selenium-webdriver/legacy/selenium-webdriver-2.39.0.d.ts" />
|
||||
|
||||
declare module protractor {
|
||||
//region Wrapped webdriver Items
|
||||
|
||||
class AbstractBuilder extends webdriver.AbstractBuilder {}
|
||||
class ActionSequence extends webdriver.ActionSequence {}
|
||||
class Alert extends webdriver.Alert {}
|
||||
class Builder extends webdriver.Builder {}
|
||||
class Button extends webdriver.Button {}
|
||||
class Capabilities extends webdriver.Capabilities {}
|
||||
class Command extends webdriver.Command {}
|
||||
class EventEmitter extends webdriver.EventEmitter {}
|
||||
class FirefoxDomExecutor extends webdriver.FirefoxDomExecutor {}
|
||||
class Locator extends webdriver.Locator {}
|
||||
class Session extends webdriver.Session {}
|
||||
class WebDriver extends webdriver.WebDriver {}
|
||||
class Browser extends webdriver.Browser {}
|
||||
class Capability extends webdriver.Capability {}
|
||||
class CommandName extends webdriver.CommandName {}
|
||||
class Key extends webdriver.Key {}
|
||||
class UnhandledAlertError extends webdriver.UnhandledAlertError {}
|
||||
|
||||
class WebElement extends webdriver.WebElement {
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
}
|
||||
|
||||
module command {
|
||||
class Command extends webdriver.Command {}
|
||||
class CommandName extends webdriver.CommandName {}
|
||||
}
|
||||
|
||||
module error {
|
||||
class Error extends webdriver.error.Error {}
|
||||
class ErrorCode extends webdriver.error.ErrorCode {}
|
||||
}
|
||||
|
||||
module events {
|
||||
class EventEmitter extends webdriver.EventEmitter {}
|
||||
}
|
||||
|
||||
module logging {
|
||||
var Preferences: any;
|
||||
|
||||
class LevelName extends webdriver.logging.LevelName {}
|
||||
class Type extends webdriver.logging.Type {}
|
||||
class Level extends webdriver.logging.Level {}
|
||||
class Entry extends webdriver.logging.Entry {}
|
||||
|
||||
function getLevel(nameOrValue: string): webdriver.logging.Level;
|
||||
function getLevel(nameOrValue: number): webdriver.logging.Level;
|
||||
}
|
||||
|
||||
module promise {
|
||||
class Promise extends webdriver.promise.Promise {}
|
||||
class Deferred extends webdriver.promise.Deferred {}
|
||||
class ControlFlow extends webdriver.promise.ControlFlow {}
|
||||
|
||||
/**
|
||||
* @return {!webdriver.promise.ControlFlow} The currently active control flow.
|
||||
*/
|
||||
function controlFlow(): webdriver.promise.ControlFlow;
|
||||
|
||||
/**
|
||||
* Creates a new control flow. The provided callback will be invoked as the
|
||||
* first task within the new flow, with the flow as its sole argument. Returns
|
||||
* a promise that resolves to the callback result.
|
||||
* @param {function(!webdriver.promise.ControlFlow)} callback The entry point
|
||||
* to the newly created flow.
|
||||
* @return {!webdriver.promise.Promise} A promise that resolves to the callback
|
||||
* result.
|
||||
*/
|
||||
function createFlow(callback: (flow: webdriver.promise.ControlFlow) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Determines whether a {@code value} should be treated as a promise.
|
||||
* Any object whose "then" property is a function will be considered a promise.
|
||||
*
|
||||
* @param {*} value The value to test.
|
||||
* @return {boolean} Whether the value is a promise.
|
||||
*/
|
||||
function isPromise(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Creates a promise that will be resolved at a set time in the future.
|
||||
* @param {number} ms The amount of time, in milliseconds, to wait before
|
||||
* resolving the promise.
|
||||
* @return {!webdriver.promise.Promise} The promise.
|
||||
*/
|
||||
function delayed(ms: number): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Creates a new deferred object.
|
||||
* @param {Function=} opt_canceller Function to call when cancelling the
|
||||
* computation of this instance's value.
|
||||
* @return {!webdriver.promise.Deferred} The new deferred object.
|
||||
*/
|
||||
function defer(opt_canceller?: any): webdriver.promise.Deferred;
|
||||
|
||||
/**
|
||||
* Creates a promise that has been resolved with the given value.
|
||||
* @param {*=} opt_value The resolved value.
|
||||
* @return {!webdriver.promise.Promise} The resolved promise.
|
||||
*/
|
||||
function fulfilled(opt_value?: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Creates a promise that has been rejected with the given reason.
|
||||
* @param {*=} opt_reason The rejection reason; may be any value, but is
|
||||
* usually an Error or a string.
|
||||
* @return {!webdriver.promise.Promise} The rejected promise.
|
||||
*/
|
||||
function rejected(opt_reason?: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Wraps a function that is assumed to be a node-style callback as its final
|
||||
* argument. This callback takes two arguments: an error value (which will be
|
||||
* null if the call succeeded), and the success value as the second argument.
|
||||
* If the call fails, the returned promise will be rejected, otherwise it will
|
||||
* be resolved with the result.
|
||||
* @param {!Function} fn The function to wrap.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* result of the provided function's callback.
|
||||
*/
|
||||
function checkedNodeCall(fn: (error: any, value: any) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Registers an observer on a promised {@code value}, returning a new promise
|
||||
* that will be resolved when the value is. If {@code value} is not a promise,
|
||||
* then the return promise will be immediately resolved.
|
||||
* @param {*} value The value to observe.
|
||||
* @param {Function=} opt_callback The function to call when the value is
|
||||
* resolved successfully.
|
||||
* @param {Function=} opt_errback The function to call when the value is
|
||||
* rejected.
|
||||
* @return {!webdriver.promise.Promise} A new promise.
|
||||
*/
|
||||
function when(value: any, opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Invokes the appropriate callback function as soon as a promised
|
||||
* {@code value} is resolved. This function is similar to
|
||||
* {@code webdriver.promise.when}, except it does not return a new promise.
|
||||
* @param {*} value The value to observe.
|
||||
* @param {Function} callback The function to call when the value is
|
||||
* resolved successfully.
|
||||
* @param {Function=} opt_errback The function to call when the value is
|
||||
* rejected.
|
||||
*/
|
||||
function asap(value: any, callback: (value: any) => any, opt_errback?: (error: any) => any): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be resolved with the input value in a
|
||||
* fully-resolved state. If the value is an array, each element will be fully
|
||||
* resolved. Likewise, if the value is an object, all keys will be fully
|
||||
* resolved. In both cases, all nested arrays and objects will also be
|
||||
* fully resolved. All fields are resolved in place; the returned promise will
|
||||
* resolve on {@code value} and not a copy.
|
||||
*
|
||||
* Warning: This function makes no checks against objects that contain
|
||||
* cyclical references:
|
||||
*
|
||||
* var value = {};
|
||||
* value['self'] = value;
|
||||
* webdriver.promise.fullyResolved(value); // Stack overflow.
|
||||
*
|
||||
* @param {*} value The value to fully resolve.
|
||||
* @return {!webdriver.promise.Promise} A promise for a fully resolved version
|
||||
* of the input value.
|
||||
*/
|
||||
function fullyResolved(value: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Changes the default flow to use when no others are active.
|
||||
* @param {!webdriver.promise.ControlFlow} flow The new default flow.
|
||||
* @throws {Error} If the default flow is not currently active.
|
||||
*/
|
||||
function setDefaultFlow(flow: webdriver.promise.ControlFlow): void;
|
||||
|
||||
}
|
||||
|
||||
module process {
|
||||
|
||||
/**
|
||||
* Queries for a named environment variable.
|
||||
* @param {string} name The name of the environment variable to look up.
|
||||
* @param {string=} opt_default The default value if the named variable is not
|
||||
* defined.
|
||||
* @return {string} The queried environment variable.
|
||||
*/
|
||||
function getEnv(name: string, opt_default?: string): string;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the current process is Node's native process
|
||||
* object.
|
||||
*/
|
||||
function isNative(): boolean;
|
||||
|
||||
/**
|
||||
* Sets an environment value. If the new value is either null or undefined, the
|
||||
* environment variable will be cleared.
|
||||
* @param {string} name The value to set.
|
||||
* @param {*} value The new value; will be coerced to a string.
|
||||
*/
|
||||
function setEnv(name: string, value: any): void;
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
interface Element {
|
||||
(locator: webdriver.Locator): ElementFinder;
|
||||
all(locator: webdriver.Locator): ElementArrayFinder;
|
||||
}
|
||||
|
||||
interface ElementFinder {
|
||||
/**
|
||||
* Schedules a command to click on this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the click command has completed.
|
||||
*/
|
||||
click(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to type a sequence on the DOM element represented by this
|
||||
* instance.
|
||||
* <p/>
|
||||
* Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is
|
||||
* processed in the keysequence, that key state is toggled until one of the
|
||||
* following occurs:
|
||||
* <ul>
|
||||
* <li>The modifier key is encountered again in the sequence. At this point the
|
||||
* state of the key is toggled (along with the appropriate keyup/down events).
|
||||
* </li>
|
||||
* <li>The {@code webdriver.Key.NULL} key is encountered in the sequence. When
|
||||
* this key is encountered, all modifier keys current in the down state are
|
||||
* released (with accompanying keyup events). The NULL key can be used to
|
||||
* simulate common keyboard shortcuts:
|
||||
* <code>
|
||||
* element.sendKeys("text was",
|
||||
* webdriver.Key.CONTROL, "a", webdriver.Key.NULL,
|
||||
* "now text is");
|
||||
* // Alternatively:
|
||||
* element.sendKeys("text was",
|
||||
* webdriver.Key.chord(webdriver.Key.CONTROL, "a"),
|
||||
* "now text is");
|
||||
* </code></li>
|
||||
* <li>The end of the keysequence is encountered. When there are no more keys
|
||||
* to type, all depressed modifier keys are released (with accompanying keyup
|
||||
* events).
|
||||
* </li>
|
||||
* </ul>
|
||||
* <strong>Note:</strong> On browsers where native keyboard events are not yet
|
||||
* supported (e.g. Firefox on OS X), key events will be synthesized. Special
|
||||
* punctionation keys will be synthesized according to a standard QWERTY en-us
|
||||
* keyboard layout.
|
||||
*
|
||||
* @param {...string} var_args The sequence of keys to
|
||||
* type. All arguments will be joined into a single sequence (var_args is
|
||||
* permitted for convenience).
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when all
|
||||
* keys have been typed.
|
||||
*/
|
||||
sendKeys(...var_args: string[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the tag/node name of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's tag name.
|
||||
*/
|
||||
getTagName(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the computed style of the element
|
||||
* represented by this instance. If the element inherits the named style from
|
||||
* its parent, the parent will be queried for its value. Where possible, color
|
||||
* values will be converted to their hex representation (e.g. #00ff00 instead of
|
||||
* rgb(0, 255, 0)).
|
||||
* <p/>
|
||||
* <em>Warning:</em> the value returned will be as the browser interprets it, so
|
||||
* it may be tricky to form a proper assertion.
|
||||
*
|
||||
* @param {string} cssStyleProperty The name of the CSS style property to look
|
||||
* up.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* requested CSS value.
|
||||
*/
|
||||
getCssValue(cssStyleProperty: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the value of the given attribute of the
|
||||
* element. Will return the current value even if it has been modified after the
|
||||
* page has been loaded. More exactly, this method will return the value of the
|
||||
* given attribute, unless that attribute is not present, in which case the
|
||||
* value of the property with the same name is returned. If neither value is
|
||||
* set, null is returned. The "style" attribute is converted as best can be to a
|
||||
* text representation with a trailing semi-colon. The following are deemed to
|
||||
* be "boolean" attributes and will be returned as thus:
|
||||
*
|
||||
* <p>async, autofocus, autoplay, checked, compact, complete, controls, declare,
|
||||
* defaultchecked, defaultselected, defer, disabled, draggable, ended,
|
||||
* formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope,
|
||||
* loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open,
|
||||
* paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
||||
* selected, spellcheck, truespeed, willvalidate
|
||||
*
|
||||
* <p>Finally, the following commonly mis-capitalized attribute/property names
|
||||
* are evaluated as expected:
|
||||
* <ul>
|
||||
* <li>"class"
|
||||
* <li>"readonly"
|
||||
* </ul>
|
||||
* @param {string} attributeName The name of the attribute to query.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* attribute's value.
|
||||
*/
|
||||
getAttribute(attributeName: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Get the visible (i.e. not hidden by CSS) innerText of this element, including
|
||||
* sub-elements, without any leading or trailing whitespace.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's visible text.
|
||||
*/
|
||||
getText(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to compute the size of this element's bounding box, in
|
||||
* pixels.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's size as a {@code {width:number, height:number}} object.
|
||||
*/
|
||||
getSize(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to compute the location of this element in page space.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to the
|
||||
* element's location as a {@code {x:number, y:number}} object.
|
||||
*/
|
||||
getLocation(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query whether the DOM element represented by this
|
||||
* instance is enabled, as dicted by the {@code disabled} attribute.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently enabled.
|
||||
*/
|
||||
isEnabled(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query whether this element is selected.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently selected.
|
||||
*/
|
||||
isSelected(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to submit the form containing this element (or this
|
||||
* element if it is a FORM element). This command is a no-op if the element is
|
||||
* not contained in a form.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the form has been submitted.
|
||||
*/
|
||||
submit(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to clear the {@code value} of this element. This command
|
||||
* has no effect if the underlying DOM element is neither a text INPUT element
|
||||
* nor a TEXTAREA element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the element has been cleared.
|
||||
*/
|
||||
clear(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test whether this element is currently displayed.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently visible on the page.
|
||||
*/
|
||||
isDisplayed(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the outer HTML of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* the element's outer HTML.
|
||||
*/
|
||||
getOuterHtml(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the inner HTML of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's inner HTML.
|
||||
*/
|
||||
getInnerHtml(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if there is at least one descendant of this
|
||||
* element that matches the given search criteria.
|
||||
*
|
||||
* <p>Note that JS locator searches cannot be restricted to a subtree of the
|
||||
* DOM. All such searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether an element could be located on the page.
|
||||
*/
|
||||
isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to find all of the descendants of this element that match
|
||||
* the given search criteria.
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the elements.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with an
|
||||
* array of located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).element(locator)
|
||||
* Calls to element may be chained to find elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementFinder} the descendent element found by the locator
|
||||
*/
|
||||
element(locator: webdriver.Locator): protractor.ElementFinder;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).all(locator)
|
||||
* Calls to element may be chained to find an array of elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementArrayFinder} the descendent elements found by the locator
|
||||
*/
|
||||
all(locator: webdriver.Locator): protractor.ElementArrayFinder;
|
||||
|
||||
find(): protractor.WebElement;
|
||||
|
||||
isPresent(): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
interface ElementArrayFinder{
|
||||
count(): webdriver.promise.Promise;
|
||||
get(index: number): protractor.WebElement;
|
||||
first(): protractor.WebElement;
|
||||
last(): protractor.WebElement;
|
||||
then(fn: (value: any) => any): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
class LocatorWithColumn extends webdriver.Locator {
|
||||
column(index: number): webdriver.Locator;
|
||||
}
|
||||
|
||||
class RepeaterLocator extends LocatorWithColumn {
|
||||
row(index: number): LocatorWithColumn;
|
||||
}
|
||||
|
||||
interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy {
|
||||
/**
|
||||
* Add a locator to this instance of ProtractorBy. This locator can then be
|
||||
* used with element(by.<name>(<args>)).
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {function|string} script A script to be run in the context of
|
||||
* the browser. This script will be passed an array of arguments
|
||||
* that begins with the element scoping the search, and then
|
||||
* contains any args passed into the locator. It should return
|
||||
* an array of elements.
|
||||
*/
|
||||
addLocator(name: string, script: any): void;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <span>{{status}}</span>
|
||||
* var status = element(by.binding('{{status}}'));
|
||||
*/
|
||||
binding(bindingDescriptor: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.select("user"));
|
||||
*/
|
||||
select(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.selectedOption("user"));
|
||||
*/
|
||||
selectedOption(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* @DEPRECATED - use 'model' instead.
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.input('user'));
|
||||
*/
|
||||
input(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.model('user'));
|
||||
*/
|
||||
model(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <textarea ng-model="user"></textarea>
|
||||
* element(by.textarea("user"));
|
||||
*/
|
||||
textarea(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <div ng-repeat = "cat in pets">
|
||||
* <span>{{cat.name}}</span>
|
||||
* <span>{{cat.age}}</span>
|
||||
* </div>
|
||||
*
|
||||
* // Returns the DIV for the second cat.
|
||||
* var secondCat = element(by.repeater("cat in pets").row(2));
|
||||
* // Returns the SPAN for the first cat's name.
|
||||
* var firstCatName = element(
|
||||
* by.repeater("cat in pets").row(1).column("{{cat.name}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements from a column
|
||||
* var ages = element(
|
||||
* by.repeater("cat in pets").column("{{cat.age}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements containing
|
||||
* // all rows of the repeater.
|
||||
* var rows = element(by.repeater("cat in pets"));
|
||||
*/
|
||||
repeater(repeatDescriptor: string): RepeaterLocator;
|
||||
|
||||
buttonText(searchText: string): webdriver.Locator;
|
||||
|
||||
partialButtonText(searchText: string): webdriver.Locator;
|
||||
}
|
||||
|
||||
var By: IProtractorLocatorStrategy;
|
||||
|
||||
class Protractor extends webdriver.WebDriver {
|
||||
|
||||
//region Constructors
|
||||
|
||||
/**
|
||||
* @param {webdriver.WebDriver} webdriver
|
||||
* @param {string=} opt_baseUrl A base URL to run get requests against.
|
||||
* @param {string=body} opt_rootElement Selector element that has an ng-app in
|
||||
* scope.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string);
|
||||
|
||||
//endregion
|
||||
|
||||
//region Properties
|
||||
|
||||
/**
|
||||
* The wrapped webdriver instance. Use this to interact with pages that do
|
||||
* not contain Angular (such as a log-in screen).
|
||||
*
|
||||
* @type {webdriver.WebDriver}
|
||||
*/
|
||||
driver: webdriver.WebDriver;
|
||||
|
||||
/**
|
||||
* All get methods will be resolved against this base URL. Relative URLs are =
|
||||
* resolved the way anchor tags resolve.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
baseUrl: string;
|
||||
|
||||
/**
|
||||
* The css selector for an element on which to find Angular. This is usually
|
||||
* 'body' but if your ng-app is on a subsection of the page it may be
|
||||
* a subelement.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
rootEl: string;
|
||||
|
||||
/**
|
||||
* If true, Protractor will not attempt to synchronize with the page before
|
||||
* performing actions. This can be harmful because Protractor will not wait
|
||||
* until $timeouts and $http calls have been processed, which can cause
|
||||
* tests to become flaky. This should be used only when necessary, such as
|
||||
* when a page continuously polls an API using $timeout.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
ignoreSynchronization: boolean;
|
||||
|
||||
/**
|
||||
* An object that holds custom test parameters.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
params: any;
|
||||
|
||||
//endregion
|
||||
|
||||
//region Methods
|
||||
|
||||
/**
|
||||
* Helper function for finding elements.
|
||||
*
|
||||
* @type {function(webdriver.Locator): ElementFinder}
|
||||
*/
|
||||
element(locator: webdriver.Locator): ElementFinder;
|
||||
|
||||
/**
|
||||
* Helper function for finding elements by css.
|
||||
*
|
||||
* @type {function(string): ElementFinder}
|
||||
*/
|
||||
$(cssLocator: string): ElementFinder;
|
||||
|
||||
/**
|
||||
* Helper function for finding arrays of elements by css.
|
||||
*
|
||||
* @type {function(string): ElementArrayFinder}
|
||||
*/
|
||||
$$(cssLocator: string): ElementArrayFinder;
|
||||
|
||||
/**
|
||||
* Instruct webdriver to wait until Angular has finished rendering and has
|
||||
* no outstanding $http calls before continuing.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* scripts return value.
|
||||
*/
|
||||
waitForAngular(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Wrap a webdriver.WebElement with protractor specific functionality.
|
||||
*
|
||||
* @param {webdriver.WebElement} element
|
||||
* @return {protractor.WebElement} the wrapped web element.
|
||||
*/
|
||||
wrapWebElement(element: webdriver.WebElement): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Add a module to load before Angular whenever Protractor.get is called.
|
||||
* Modules will be registered after existing modules already on the page,
|
||||
* so any module registered here will override preexisting modules with the same
|
||||
* name.
|
||||
*
|
||||
* @param {!string} name The name of the module to load or override.
|
||||
* @param {!string|Function} script The JavaScript to load the module.
|
||||
*/
|
||||
addMockModule(name: string, script: string): void;
|
||||
addMockModule(name: string, script: any): void;
|
||||
|
||||
/**
|
||||
* Clear the list of registered mock modules.
|
||||
*/
|
||||
clearMockModules(): void;
|
||||
|
||||
/**
|
||||
* Returns the current absolute url from AngularJS.
|
||||
*/
|
||||
getLocationAbsUrl(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Pauses the test and injects some helper functions into the browser, so that
|
||||
* debugging may be done in the browser console.
|
||||
*
|
||||
* This should be used under node in debug mode, i.e. with
|
||||
* protractor debug <configuration.js>
|
||||
*
|
||||
* While in the debugger, commands can be scheduled through webdriver by
|
||||
* entering the repl:
|
||||
* debug> repl
|
||||
* Press Ctrl + C to leave rdebug repl
|
||||
* > ptor.findElement(protractor.By.input('user').sendKeys('Laura'));
|
||||
* > ptor.debugger();
|
||||
* debug> c
|
||||
*
|
||||
* This will run the sendKeys command as the next task, then re-enter the
|
||||
* debugger.
|
||||
*/
|
||||
debugger(): void;
|
||||
|
||||
/**
|
||||
* Schedule a command to find an element on the page. If the element cannot be
|
||||
* found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned
|
||||
* by the driver. Unlike other commands, this error cannot be suppressed. In
|
||||
* other words, scheduling a command to find an element doubles as an assert
|
||||
* that the element is present on the page. To test whether an element is
|
||||
* present on the page, use {@code #isElementPresent} instead.
|
||||
*
|
||||
* <p>The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two statements
|
||||
* are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = driver.findElement(By.id('foo'));
|
||||
* var e2 = driver.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
*
|
||||
* <p>When running in the browser, a WebDriver cannot manipulate DOM elements
|
||||
* directly; it may do so only through a {@link webdriver.WebElement} reference.
|
||||
* This function may be used to generate a WebElement from a DOM element. A
|
||||
* reference to the DOM element will be stored in a known location and this
|
||||
* driver will attempt to retrieve it through {@link #executeScript}. If the
|
||||
* element cannot be found (eg, it belongs to a different document than the
|
||||
* one this instance is currently focused on), a
|
||||
* {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned.
|
||||
*
|
||||
* @param {!(webdriver.Locator|Object.<string>|Element)} locatorOrElement The
|
||||
* locator strategy to use when searching for the element, or the actual
|
||||
* DOM element to be located by the server.
|
||||
* @param {...} var_args Arguments to pass to {@code #executeScript} if using a
|
||||
* JavaScript locator. Otherwise ignored.
|
||||
* @return {!protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement;
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of Protractor by wrapping a webdriver instance.
|
||||
*
|
||||
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
|
||||
* @param {string=} opt_baseUrl A URL to prepend to relative gets.
|
||||
* @return {Protractor}
|
||||
*/
|
||||
function wrapDriver(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string): Protractor;
|
||||
|
||||
/**
|
||||
* Set a singleton instance of protractor.
|
||||
* @param {Protractor} ptor
|
||||
*/
|
||||
function setInstance(ptor: Protractor): void;
|
||||
|
||||
/**
|
||||
* Get the singleton instance.
|
||||
* @return {Protractor}
|
||||
*/
|
||||
function getInstance(): Protractor;
|
||||
|
||||
}
|
||||
|
||||
interface cssSelectorHelper {
|
||||
(cssLocator: string): protractor.ElementFinder;
|
||||
}
|
||||
|
||||
declare var browser: protractor.Protractor;
|
||||
declare var by: protractor.IProtractorLocatorStrategy;
|
||||
declare var element: protractor.Element;
|
||||
declare var $: cssSelectorHelper;
|
||||
declare var $$: cssSelectorHelper;
|
||||
|
||||
declare module 'protractor' {
|
||||
export = protractor;
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
/// <reference path="angular-protractor-1.0.0-rc4.d.ts" />
|
||||
|
||||
function TestWebDriverExports() {
|
||||
var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
|
||||
var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
|
||||
|
||||
var button: protractor.Button = new protractor.Button();
|
||||
var baseButton: webdriver.Button = button;
|
||||
|
||||
var key: string = protractor.Key.ADD;
|
||||
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
|
||||
|
||||
var driver: protractor.WebDriver = new protractor.Builder().
|
||||
withCapabilities(protractor.Capabilities.chrome()).
|
||||
build();
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
|
||||
var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
|
||||
var baseAction: webdriver.ActionSequence = action;
|
||||
|
||||
var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
|
||||
var baseAlert: webdriver.Alert = alert;
|
||||
|
||||
var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
|
||||
var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
|
||||
|
||||
var browser: string = protractor.Browser.ANDROID;
|
||||
|
||||
var builder: protractor.Builder = new protractor.Builder();
|
||||
var baseBuilder: webdriver.Builder = builder;
|
||||
|
||||
var capability: string = protractor.Capability.BROWSER_NAME;
|
||||
|
||||
var capabilities: protractor.Capabilities = protractor.Capabilities.chrome();
|
||||
var baseCapabilities: webdriver.Capabilities = capabilities;
|
||||
|
||||
var commandName: string = protractor.CommandName.CLICK_ELEMENT;
|
||||
|
||||
var command: protractor.Command = new protractor.Command(protractor.CommandName.CLICK);
|
||||
var baseCommand: webdriver.Command = command;
|
||||
|
||||
var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
|
||||
var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
|
||||
|
||||
var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
|
||||
var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
|
||||
|
||||
var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
|
||||
var baseWebElement: webdriver.WebElement = webElement;
|
||||
|
||||
var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
|
||||
var baseLocator: webdriver.Locator = locator;
|
||||
|
||||
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
|
||||
var baseSession: webdriver.Session = session;
|
||||
|
||||
locator = protractor.By.name('name');
|
||||
|
||||
// logging module
|
||||
|
||||
var levelName: string = protractor.logging.LevelName.ALL;
|
||||
var loggingType: string = protractor.logging.Type.CLIENT;
|
||||
|
||||
var level: webdriver.logging.Level = protractor.logging.Level.ALL;
|
||||
|
||||
var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
|
||||
var baseEntry: webdriver.logging.Entry = entry;
|
||||
|
||||
level = protractor.logging.getLevel('DEBUG');
|
||||
|
||||
protractor.logging.Preferences = { a: 123 };
|
||||
|
||||
// promise module
|
||||
|
||||
var promise: protractor.promise.Promise = new protractor.promise.Promise();
|
||||
var basePromise: webdriver.promise.Promise = promise;
|
||||
|
||||
var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
|
||||
var baseDeferred: webdriver.promise.Deferred = deferred;
|
||||
|
||||
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
|
||||
var baseFlow: webdriver.promise.ControlFlow = flow;
|
||||
|
||||
protractor.promise.asap(promise, function(value: any){ return true; });
|
||||
protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
|
||||
|
||||
promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
|
||||
|
||||
flow = protractor.promise.controlFlow();
|
||||
|
||||
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
|
||||
|
||||
deferred = protractor.promise.defer(function() {});
|
||||
deferred = protractor.promise.defer(function(reason?: any) {});
|
||||
|
||||
promise = protractor.promise.delayed(123);
|
||||
|
||||
promise = protractor.promise.fulfilled();
|
||||
promise = protractor.promise.fulfilled({a: 123});
|
||||
|
||||
promise = protractor.promise.fullyResolved({a: 123});
|
||||
|
||||
var isPromise: boolean = protractor.promise.isPromise('ABC');
|
||||
|
||||
promise = protractor.promise.rejected({a: 123});
|
||||
|
||||
protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
|
||||
|
||||
promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
|
||||
|
||||
// error module
|
||||
|
||||
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
|
||||
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
|
||||
// process module
|
||||
|
||||
var isNative: boolean = protractor.process.isNative();
|
||||
var value: string;
|
||||
|
||||
value = protractor.process.getEnv('name');
|
||||
value = protractor.process.getEnv('name', 'default');
|
||||
|
||||
protractor.process.setEnv('name', 'value');
|
||||
protractor.process.setEnv('name', 123);
|
||||
|
||||
}
|
||||
|
||||
function TestProtractor() {
|
||||
var ptor: protractor.Protractor;
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
ptor = new protractor.Protractor(driver);
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl');
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
|
||||
ptor = protractor.getInstance();
|
||||
protractor.setInstance(ptor);
|
||||
|
||||
ptor = protractor.wrapDriver(driver);
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl');
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
|
||||
|
||||
ptor = browser;
|
||||
|
||||
driver = ptor.driver;
|
||||
var baseUrl: string = ptor.baseUrl;
|
||||
var rootEl: string = ptor.rootEl;
|
||||
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
|
||||
var params: any = ptor.params;
|
||||
|
||||
ptor.debugger();
|
||||
|
||||
var webElement: protractor.WebElement = ptor.findElement(by.css('.class'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
promise = ptor.findElements(by.css('.class'));
|
||||
promise = ptor.isElementPresent(by.css('.class'));
|
||||
promise = ptor.isElementPresent(webElement);
|
||||
|
||||
ptor.clearMockModules();
|
||||
ptor.addMockModule('name', 'script');
|
||||
ptor.addMockModule('name', function() {});
|
||||
ptor.removeMockModule('name');
|
||||
ptor.waitForAngular();
|
||||
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
var elementArrayFinder: protractor.ElementArrayFinder;
|
||||
|
||||
elementFinder = ptor.element(by.id('ABC'));
|
||||
elementFinder = ptor.$('.class');
|
||||
|
||||
elementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
|
||||
ptor.setLocation('webaddress.com');
|
||||
|
||||
promise = ptor.get('webaddress.com');
|
||||
promise = ptor.get('webdaddress.com', 45);
|
||||
ptor.refresh();
|
||||
ptor.refresh(45);
|
||||
var navigation: webdriver.WebDriverNavigation = ptor.navigate();
|
||||
ptor.pause();
|
||||
ptor.pause(8080);
|
||||
}
|
||||
|
||||
function TestElement() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.className('class'));
|
||||
}
|
||||
|
||||
function TestElementFinder() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = elementFinder.click();
|
||||
promise = elementFinder.allowAnimations('string');
|
||||
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
promise = elementFinder.getTagName();
|
||||
promise = elementFinder.getCssValue('display');
|
||||
promise = elementFinder.getAttribute('atribute');
|
||||
promise = elementFinder.getText();
|
||||
promise = elementFinder.getSize();
|
||||
promise = elementFinder.getLocation();
|
||||
promise = elementFinder.isEnabled();
|
||||
promise = elementFinder.isSelected();
|
||||
promise = elementFinder.submit();
|
||||
promise = elementFinder.clear();
|
||||
promise = elementFinder.isDisplayed();
|
||||
promise = elementFinder.getOuterHtml();
|
||||
promise = elementFinder.getInnerHtml();
|
||||
promise = elementFinder.isElementPresent(by.id('id'));
|
||||
promise = elementFinder.$('.class');
|
||||
promise = elementFinder.$$('.class');
|
||||
promise = elementFinder.evaluate('expression');
|
||||
promise = elementFinder.isPresent();
|
||||
|
||||
var webElement: webdriver.WebElement;
|
||||
}
|
||||
|
||||
function TestElementArrayFinder() {
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
|
||||
var driverElementArray: webdriver.WebElement[] = elementArrayFinder.getWebElements();
|
||||
elementFinder = elementArrayFinder.get(42);
|
||||
elementFinder = elementArrayFinder.first();
|
||||
elementFinder = elementArrayFinder.last();
|
||||
promise = elementArrayFinder.count();
|
||||
promise = elementArrayFinder.asElementFinders_();
|
||||
elementArrayFinder.each(function(element: protractor.ElementFinder){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
|
||||
return element.getText().then((text: string) => {
|
||||
return text === "foo";
|
||||
});
|
||||
});
|
||||
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder){
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder, index: number, array: protractor.ElementFinder[]){
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
elementArrayFinder.then(function(underlyingElementFinders: protractor.ElementFinder[]){
|
||||
//nothing
|
||||
});
|
||||
}
|
||||
|
||||
// This function tests the angular specific locator strategies.
|
||||
function TestLocatorStrategies() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
// Protractor Specific Locators
|
||||
protractor.By.addLocator('customLocator', 'script');
|
||||
protractor.By.addLocator('customLocator2', function(){
|
||||
// nothing
|
||||
});
|
||||
webElement = ptor.findElement(protractor.By.binding('binding'));
|
||||
webElement = ptor.findElement(protractor.By.exactBinding('exactBinding'));
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater').column(0));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater').row(0));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater').row(0).column(0));
|
||||
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
webElement = ptor.findElement(protractor.By.cssContainingText('cssSelector', 'search text'));
|
||||
webElement = ptor.findElement(protractor.By.options('options'));
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,47 +0,0 @@
|
||||
/// <reference path="selenium-webdriver.d.ts" />
|
||||
|
||||
function TestChromeDriver() {
|
||||
var driver: chrome.Driver = new chrome.Driver();
|
||||
driver = new chrome.Driver(webdriver.Capabilities.chrome());
|
||||
driver = new chrome.Driver(webdriver.Capabilities.chrome(), new webdriver.promise.ControlFlow());
|
||||
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
|
||||
function TestChromeOptions() {
|
||||
var 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.detachDriver(true);
|
||||
options = options.setChromeBinaryPath("path");
|
||||
options = options.setChromeLogFile("logfile");
|
||||
options = options.setLocalState("state");
|
||||
options = options.setLoggingPrefs(new webdriver.logging.Preferences());
|
||||
options = options.setProxy({ proxyType: "proxyType" });
|
||||
options = options.setUserPreferences("preferences");
|
||||
var capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
capabilities = options.toCapabilities(webdriver.Capabilities.chrome());
|
||||
var values: chrome.IOptionsValues = options.toJSON();
|
||||
}
|
||||
|
||||
function TestServiceBuilder() {
|
||||
var builder: chrome.ServiceBuilder = new chrome.ServiceBuilder();
|
||||
builder = new chrome.ServiceBuilder("exe");
|
||||
|
||||
var anything: any = builder.build();
|
||||
builder = builder.enableVerboseLogging();
|
||||
builder = builder.loggingTo("path");
|
||||
builder = builder.setNumHttpThreads(5);
|
||||
builder = builder.setStdio("config");
|
||||
builder = builder.setStdio(["A", "B"]);
|
||||
builder = builder.setUrlBasePath("path");
|
||||
builder = builder.usingPort(8080);
|
||||
builder = builder.withEnvironment({ "A": "a", "B": "b" });
|
||||
}
|
||||
|
||||
function TestChromeModule() {
|
||||
var service: any = chrome.getDefaultService();
|
||||
chrome.setDefaultService({});
|
||||
}
|
||||
269
selenium-webdriver/chrome.d.ts
vendored
269
selenium-webdriver/chrome.d.ts
vendored
@@ -1,269 +0,0 @@
|
||||
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: 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 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): void;
|
||||
}
|
||||
|
||||
declare module 'selenium-webdriver/chrome' {
|
||||
export = chrome;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/// <reference path="selenium-webdriver.d.ts" />
|
||||
/// <reference path="executors.d.ts" />
|
||||
|
||||
function TestExecutors() {
|
||||
var exec: webdriver.CommandExecutor = executors.createExecutor("url");
|
||||
exec = executors.createExecutor(new webdriver.promise.Promise<string>());
|
||||
}
|
||||
|
||||
13
selenium-webdriver/executors.d.ts
vendored
13
selenium-webdriver/executors.d.ts
vendored
@@ -1,13 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/// <reference path="selenium-webdriver.d.ts" />
|
||||
|
||||
function TestBinary() {
|
||||
var binary: firefox.Binary = new firefox.Binary();
|
||||
binary = new firefox.Binary("exe");
|
||||
|
||||
binary.addArguments("A", "B", "C");
|
||||
var promise: webdriver.promise.Promise<void> = binary.kill();
|
||||
binary.launch("profile").then(function (result: any) { });
|
||||
}
|
||||
|
||||
function TestFirefoxDriver() {
|
||||
var driver: firefox.Driver = new firefox.Driver();
|
||||
driver = new chrome.Driver(webdriver.Capabilities.firefox());
|
||||
driver = new chrome.Driver(webdriver.Capabilities.firefox(), new webdriver.promise.ControlFlow());
|
||||
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
|
||||
function TestFirefoxOptions() {
|
||||
var options: firefox.Options = new firefox.Options();
|
||||
|
||||
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" });
|
||||
var capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
var capabilities: webdriver.Capabilities = options.toCapabilities({});
|
||||
}
|
||||
|
||||
function TestFirefoxProfile() {
|
||||
var profile: firefox.Profile = new firefox.Profile();
|
||||
profile = new firefox.Profile("dir");
|
||||
|
||||
var bool: boolean = profile.acceptUntrustedCerts();
|
||||
profile.addExtension("ext");
|
||||
bool = profile.assumeUntrustedCertIssuer();
|
||||
profile.encode().then(function (prof: string) { });
|
||||
var num: number = profile.getPort();
|
||||
var 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);
|
||||
var stringPromise: webdriver.promise.Promise<string> = profile.writeToDisk();
|
||||
stringPromise = profile.writeToDisk(true);
|
||||
}
|
||||
238
selenium-webdriver/firefox.d.ts
vendored
238
selenium-webdriver/firefox.d.ts
vendored
@@ -1,238 +0,0 @@
|
||||
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[]): 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>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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): 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>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'selenium-webdriver/firefox' {
|
||||
export = firefox;
|
||||
}
|
||||
@@ -1,917 +0,0 @@
|
||||
/// <reference path="selenium-webdriver-2.39.0.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;
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
var env: string = webdriver.Builder.SESSION_ID_ENV;
|
||||
}
|
||||
|
||||
function TestActionSequence() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var sequence: webdriver.ActionSequence = new webdriver.ActionSequence(driver);
|
||||
var element: webdriver.WebElement = new webdriver.WebElement(driver, 'id');
|
||||
|
||||
// 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", "B", "C"]);
|
||||
|
||||
var promise: webdriver.promise.Promise = sequence.perform();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
promise = alert.accept();
|
||||
promise = alert.dismiss();
|
||||
promise = alert.getText();
|
||||
promise = alert.sendKeys("ABC");
|
||||
}
|
||||
|
||||
function TestBrowser() {
|
||||
var 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() {
|
||||
var button: number;
|
||||
|
||||
button = webdriver.Button.LEFT;
|
||||
button = webdriver.Button.MIDDLE;
|
||||
button = webdriver.Button.RIGHT;
|
||||
}
|
||||
|
||||
function TestCapabilities() {
|
||||
var capabilities: webdriver.Capabilities = new webdriver.Capabilities();
|
||||
capabilities = new webdriver.Capabilities(webdriver.Capabilities.chrome());
|
||||
var objCapabilities: any = {};
|
||||
objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.PHANTOM_JS;
|
||||
capabilities = new webdriver.Capabilities(objCapabilities);
|
||||
|
||||
var anything: any = capabilities.get(webdriver.Capability.SECURE_SSL);
|
||||
var 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);
|
||||
|
||||
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() {
|
||||
var capability: string;
|
||||
|
||||
capability = webdriver.Capability.ACCEPT_SSL_CERTS;
|
||||
capability = webdriver.Capability.BROWSER_NAME;
|
||||
capability = webdriver.Capability.HANDLES_ALERTS;
|
||||
capability = webdriver.Capability.LOGGING_PREFS;
|
||||
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;
|
||||
capability = webdriver.Capability.TAKES_SCREENSHOT;
|
||||
capability = webdriver.Capability.UNEXPECTED_ALERT_BEHAVIOR;
|
||||
capability = webdriver.Capability.VERSION;
|
||||
}
|
||||
|
||||
function TestCommand() {
|
||||
var command: webdriver.Command = new webdriver.Command(webdriver.CommandName.ADD_COOKIE);
|
||||
|
||||
var name: string = command.getName();
|
||||
var param: any = command.getParameter("param");
|
||||
|
||||
var params: any = command.getParameters();
|
||||
|
||||
command = command.setParameter("param", 123);
|
||||
command = command.setParameters({ param: 123 });
|
||||
}
|
||||
|
||||
function TestCommandExecutor() {
|
||||
var c: webdriver.CommandExecutor = { execute: function(command: webdriver.Command, callback: (error: Error, obj: any) => any) {} };
|
||||
}
|
||||
|
||||
function TestCommandName() {
|
||||
var 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() {
|
||||
var emitter: webdriver.EventEmitter = new webdriver.EventEmitter();
|
||||
|
||||
var callback = function (a: number, b: number, c: number) {};
|
||||
|
||||
emitter = emitter.addListener('ABC', callback);
|
||||
|
||||
emitter.emit('ABC', 1, 2, 3);
|
||||
|
||||
var listeners = emitter.listeners('ABC');
|
||||
var length: number = listeners.length;
|
||||
var listenerInfo = listeners[0];
|
||||
if (listenerInfo.oneshot) {
|
||||
listenerInfo.fn.apply(listenerInfo.scope, [1, 2, 3]);
|
||||
}
|
||||
|
||||
emitter = emitter.on('ABC', callback);
|
||||
|
||||
emitter = emitter.once('ABC', callback);
|
||||
|
||||
emitter = emitter.removeListener('ABC', callback);
|
||||
|
||||
emitter.removeAllListeners('ABC');
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
key = webdriver.Key.chord(webdriver.Key.NUMPAD0, webdriver.Key.NUMPAD1);
|
||||
}
|
||||
|
||||
function TestLocator() {
|
||||
var locator: webdriver.Locator = new webdriver.Locator('id', 'ABC');
|
||||
|
||||
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'});
|
||||
|
||||
locator = webdriver.Locator.createFromObj({id: 'ABC'});
|
||||
|
||||
locator = webdriver.Locator.Strategy.id('ABC');
|
||||
|
||||
locator = webdriver.By.id('ABC');
|
||||
}
|
||||
|
||||
function TestSession() {
|
||||
var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
|
||||
var capabilitiesObj: any = {};
|
||||
capabilitiesObj[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.ANDROID;
|
||||
capabilitiesObj[webdriver.Capability.PLATFORM] = 'ANDROID';
|
||||
session = new webdriver.Session('ABC', capabilitiesObj);
|
||||
|
||||
var capabilities: webdriver.Capabilities = session.getCapabilities();
|
||||
var capability: any = session.getCapability(webdriver.Capability.BROWSER_NAME);
|
||||
var id: string = session.getId();
|
||||
var data: string = session.toJSON();
|
||||
}
|
||||
|
||||
function TestUnhandledAlertError() {
|
||||
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');
|
||||
var error = new webdriver.UnhandledAlertError('An error', alert);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
|
||||
alert = error.getAlert();
|
||||
}
|
||||
|
||||
function TestWebDriverLogs() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var logs: webdriver.WebDriverLogs = webdriver.WebDriver.Logs;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = logs.get(webdriver.logging.Type.BROWSER);
|
||||
promise = logs.getAvailableLogTypes();
|
||||
}
|
||||
|
||||
function TestWebDriverNavigation() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var navigation: webdriver.WebDriverNavigation = webdriver.WebDriver.Navigation;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = navigation.back();
|
||||
promise = navigation.forward();
|
||||
promise = navigation.refresh();
|
||||
promise = navigation.to('http://google.com');
|
||||
}
|
||||
|
||||
function TestWebDriverOptions() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var options: webdriver.WebDriverOptions = webdriver.WebDriver.Options;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
// Add Cookie
|
||||
promise = options.addCookie('name', 'value');
|
||||
promise = options.addCookie('name', 'value', 'path');
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain');
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain', true);
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain', true, 123);
|
||||
promise = options.addCookie('name', 'value', 'path', 'domain', true, Date.now());
|
||||
|
||||
promise = options.deleteAllCookies();
|
||||
promise = options.deleteCookie('name');
|
||||
promise = options.getCookie('name');
|
||||
promise = options.getCookies();
|
||||
|
||||
var logs: webdriver.WebDriverLogs = options.logs();
|
||||
var timeouts: webdriver.WebDriverTimeouts = options.timeouts();
|
||||
var window: webdriver.WebDriverWindow = options.window();
|
||||
}
|
||||
|
||||
function TestWebDriverTargetLocator() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var locator: webdriver.WebDriverTargetLocator = webdriver.WebDriver.TargetLocator;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
var element: webdriver.WebElement = locator.activeElement();
|
||||
var alert: webdriver.Alert = locator.alert();
|
||||
promise = locator.defaultContent();
|
||||
promise = locator.frame('name');
|
||||
promise = locator.frame(1);
|
||||
promise = locator.window('nameOrHandle');
|
||||
}
|
||||
|
||||
function TestWebDriverTimeouts() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var timeouts: webdriver.WebDriverTimeouts = webdriver.WebDriver.Timeouts;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = timeouts.implicitlyWait(123);
|
||||
promise = timeouts.pageLoadTimeout(123);
|
||||
promise = timeouts.setScriptTimeout(123);
|
||||
}
|
||||
|
||||
function TestWebDriverWindow() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var window: webdriver.WebDriverWindow = webdriver.WebDriver.Window;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = window.getPosition();
|
||||
promise = window.getSize();
|
||||
promise = window.maximize();
|
||||
promise = window.setPosition(12, 34);
|
||||
promise = 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 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);
|
||||
|
||||
// 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);
|
||||
|
||||
promise = 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);
|
||||
|
||||
// ExecuteScript
|
||||
promise = driver.executeScript('function(){}');
|
||||
promise = driver.executeScript('function(){}', 1, 2, 3);
|
||||
promise = driver.executeScript(function(){});
|
||||
promise = driver.executeScript(function(a: number){}, 1);
|
||||
|
||||
var element: webdriver.WebElement;
|
||||
element = driver.findElement(webdriver.By.id('ABC'));
|
||||
element = driver.findElement({id: 'ABC'});
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
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');
|
||||
|
||||
driver = webdriver.WebDriver.attachToSession(executor, 'ABC');
|
||||
driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android());
|
||||
}
|
||||
|
||||
function TestWebElement() {
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
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);
|
||||
|
||||
var deferred: webdriver.promise.Deferred = element;
|
||||
|
||||
promise = element.clear();
|
||||
promise = 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);
|
||||
|
||||
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);
|
||||
|
||||
promise = element.getAttribute('class');
|
||||
promise = 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();
|
||||
|
||||
promise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, 'ID2'));
|
||||
|
||||
var key: string = webdriver.WebElement.ELEMENT_KEY;
|
||||
}
|
||||
|
||||
function TestLogging() {
|
||||
webdriver.logging.Preferences['name'] = 'ABC';
|
||||
var 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;
|
||||
|
||||
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;
|
||||
type = webdriver.logging.Type.DRIVER;
|
||||
type = webdriver.logging.Type.PERFORMANCE;
|
||||
type = webdriver.logging.Type.SERVER;
|
||||
}
|
||||
|
||||
function TestLoggingEntry() {
|
||||
var 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);
|
||||
|
||||
var entryObj: any = entry.toJSON();
|
||||
|
||||
var message: string = entry.message;
|
||||
var timestamp: number = entry.timestamp;
|
||||
var type: string = entry.type;
|
||||
|
||||
entry = webdriver.logging.Entry.fromClosureLogRecord({});
|
||||
entry = webdriver.logging.Entry.fromClosureLogRecord({}, webdriver.logging.Type.DRIVER);
|
||||
}
|
||||
|
||||
function TestProcess() {
|
||||
var isNative: boolean = webdriver.process.isNative();
|
||||
var value: string;
|
||||
|
||||
value = webdriver.process.getEnv('name');
|
||||
value = webdriver.process.getEnv('name', 'default');
|
||||
|
||||
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; });
|
||||
|
||||
var flow: webdriver.promise.ControlFlow = webdriver.promise.controlFlow();
|
||||
|
||||
promise = webdriver.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
|
||||
|
||||
var deferred: webdriver.promise.Deferred;
|
||||
deferred = webdriver.promise.defer(function() {});
|
||||
deferred = webdriver.promise.defer(function(reason?: any) {});
|
||||
|
||||
promise = webdriver.promise.delayed(123);
|
||||
|
||||
promise = webdriver.promise.fulfilled();
|
||||
promise = webdriver.promise.fulfilled({a: 123});
|
||||
|
||||
promise = webdriver.promise.fullyResolved({a: 123});
|
||||
|
||||
var isPromise: boolean = webdriver.promise.isPromise('ABC');
|
||||
|
||||
promise = 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; });
|
||||
}
|
||||
|
||||
function TestControlFlow() {
|
||||
var flow: webdriver.promise.ControlFlow;
|
||||
flow = new webdriver.promise.ControlFlow();
|
||||
flow = new webdriver.promise.ControlFlow({clearInterval: function(a: number) {},
|
||||
clearTimeout: function(a: number) {},
|
||||
setInterval: function(a: () => void, b: number) { return 2; },
|
||||
setTimeout: function(a: () => void, b: number) { return 2; }});
|
||||
|
||||
var emitter: webdriver.EventEmitter = flow;
|
||||
|
||||
var eventType: string;
|
||||
|
||||
eventType = webdriver.promise.ControlFlow.EventType.IDLE;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.SCHEDULE_TASK;
|
||||
eventType = webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION;
|
||||
|
||||
var e: any = flow.annotateError(new Error('Error'));
|
||||
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = flow.await(promise);
|
||||
|
||||
flow.clearHistory();
|
||||
|
||||
promise = flow.execute(function() { return promise; });
|
||||
promise = flow.execute(function() { return promise; }, 'Description');
|
||||
|
||||
var history: string[] = flow.getHistory();
|
||||
|
||||
var schedule: string = flow.getSchedule();
|
||||
|
||||
flow.reset();
|
||||
|
||||
promise = flow.timeout(123);
|
||||
promise = 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');
|
||||
|
||||
var timer: webdriver.promise.IControlFlowTimer = flow.timer;
|
||||
|
||||
timer = webdriver.promise.ControlFlow.defaultTimer;
|
||||
var loopFrequency: number = webdriver.promise.ControlFlow.EVENT_LOOP_FREQUENCY;
|
||||
}
|
||||
|
||||
function TestDeferred() {
|
||||
var deferred: webdriver.promise.Deferred;
|
||||
|
||||
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());
|
||||
|
||||
var promise: webdriver.promise.Promise = deferred;
|
||||
|
||||
deferred.errback(new Error('Error'));
|
||||
deferred.errback('Error');
|
||||
deferred.fulfill(123);
|
||||
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 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);
|
||||
|
||||
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; });
|
||||
}
|
||||
|
||||
function TestErrorCode() {
|
||||
var errorCode: number;
|
||||
|
||||
errorCode = webdriver.error.ErrorCode.ELEMENT_NOT_SELECTABLE;
|
||||
errorCode = webdriver.error.ErrorCode.ELEMENT_NOT_VISIBLE;
|
||||
errorCode = webdriver.error.ErrorCode.IME_ENGINE_ACTIVATION_FAILED;
|
||||
errorCode = webdriver.error.ErrorCode.IME_NOT_AVAILABLE;
|
||||
errorCode = webdriver.error.ErrorCode.INVALID_COOKIE_DOMAIN;
|
||||
errorCode = webdriver.error.ErrorCode.INVALID_ELEMENT_COORDINATES;
|
||||
errorCode = webdriver.error.ErrorCode.INVALID_ELEMENT_STATE;
|
||||
errorCode = webdriver.error.ErrorCode.INVALID_SELECTOR_ERROR;
|
||||
errorCode = webdriver.error.ErrorCode.INVALID_XPATH_SELECTOR;
|
||||
errorCode = webdriver.error.ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPE;
|
||||
errorCode = webdriver.error.ErrorCode.JAVASCRIPT_ERROR;
|
||||
errorCode = webdriver.error.ErrorCode.METHOD_NOT_ALLOWED;
|
||||
errorCode = webdriver.error.ErrorCode.MODAL_DIALOG_OPENED;
|
||||
errorCode = webdriver.error.ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS;
|
||||
errorCode = webdriver.error.ErrorCode.NO_MODAL_DIALOG_OPEN;
|
||||
errorCode = webdriver.error.ErrorCode.NO_SUCH_ELEMENT;
|
||||
errorCode = webdriver.error.ErrorCode.NO_SUCH_FRAME;
|
||||
errorCode = webdriver.error.ErrorCode.NO_SUCH_WINDOW;
|
||||
errorCode = webdriver.error.ErrorCode.SCRIPT_TIMEOUT;
|
||||
errorCode = webdriver.error.ErrorCode.SESSION_NOT_CREATED;
|
||||
errorCode = webdriver.error.ErrorCode.SQL_DATABASE_ERROR;
|
||||
errorCode = webdriver.error.ErrorCode.STALE_ELEMENT_REFERENCE;
|
||||
errorCode = webdriver.error.ErrorCode.SUCCESS;
|
||||
errorCode = webdriver.error.ErrorCode.TIMEOUT;
|
||||
errorCode = webdriver.error.ErrorCode.UNABLE_TO_SET_COOKIE;
|
||||
errorCode = webdriver.error.ErrorCode.UNKNOWN_COMMAND;
|
||||
errorCode = webdriver.error.ErrorCode.UNKNOWN_ERROR;
|
||||
errorCode = webdriver.error.ErrorCode.UNSUPPORTED_OPERATION;
|
||||
errorCode = webdriver.error.ErrorCode.XPATH_LOOKUP_ERROR;
|
||||
}
|
||||
|
||||
function TestError() {
|
||||
var error: webdriver.error.Error;
|
||||
|
||||
error = new webdriver.error.Error(webdriver.error.ErrorCode.ELEMENT_NOT_SELECTABLE);
|
||||
error = new webdriver.error.Error(webdriver.error.ErrorCode.ELEMENT_NOT_SELECTABLE, 'Message');
|
||||
|
||||
var code: number = error.code;
|
||||
var state: string = error.state;
|
||||
var message: string = error.message;
|
||||
var name: string = error.name;
|
||||
var stack: string = error.stack;
|
||||
var isAutomationError: boolean = error.isAutomationError;
|
||||
var errorStr: string = error.toString();
|
||||
|
||||
state = webdriver.error.Error.State.ELEMENT_NOT_SELECTABLE
|
||||
state = webdriver.error.Error.State.ELEMENT_NOT_VISIBLE;
|
||||
state = webdriver.error.Error.State.IME_ENGINE_ACTIVATION_FAILED;
|
||||
state = webdriver.error.Error.State.IME_NOT_AVAILABLE;
|
||||
state = webdriver.error.Error.State.INVALID_COOKIE_DOMAIN;
|
||||
state = webdriver.error.Error.State.INVALID_ELEMENT_COORDINATES;
|
||||
state = webdriver.error.Error.State.INVALID_ELEMENT_STATE;
|
||||
state = webdriver.error.Error.State.INVALID_SELECTOR;
|
||||
state = webdriver.error.Error.State.JAVASCRIPT_ERROR;
|
||||
state = webdriver.error.Error.State.MOVE_TARGET_OUT_OF_BOUNDS;
|
||||
state = webdriver.error.Error.State.NO_SUCH_ALERT;
|
||||
state = webdriver.error.Error.State.NO_SUCH_DOM
|
||||
state = webdriver.error.Error.State.NO_SUCH_ELEMENT;
|
||||
state = webdriver.error.Error.State.NO_SUCH_FRAME;
|
||||
state = webdriver.error.Error.State.NO_SUCH_WINDOW;
|
||||
state = webdriver.error.Error.State.SCRIPT_TIMEOUT;
|
||||
state = webdriver.error.Error.State.SESSION_NOT_CREATED;
|
||||
state = webdriver.error.Error.State.STALE_ELEMENT_REFERENCE;
|
||||
state = webdriver.error.Error.State.SUCCESS;
|
||||
state = webdriver.error.Error.State.TIMEOUT;
|
||||
state = webdriver.error.Error.State.UNABLE_TO_SET_COOKIE;
|
||||
state = webdriver.error.Error.State.UNEXPECTED_ALERT_OPEN
|
||||
state = webdriver.error.Error.State.UNKNOWN_COMMAND;
|
||||
state = webdriver.error.Error.State.UNKNOWN_ERROR;
|
||||
state = webdriver.error.Error.State.UNSUPPORTED_OPERATION;
|
||||
}
|
||||
3225
selenium-webdriver/legacy/selenium-webdriver-2.39.0.d.ts
vendored
3225
selenium-webdriver/legacy/selenium-webdriver-2.39.0.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,107 @@
|
||||
/// <reference path="selenium-webdriver.d.ts" />
|
||||
/// <reference path="executors.d.ts" />
|
||||
|
||||
function TestChromeDriver() {
|
||||
var driver: chrome.Driver = new chrome.Driver();
|
||||
driver = new chrome.Driver(webdriver.Capabilities.chrome());
|
||||
driver = new chrome.Driver(webdriver.Capabilities.chrome(), new webdriver.promise.ControlFlow());
|
||||
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
|
||||
function TestChromeOptions() {
|
||||
var 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.detachDriver(true);
|
||||
options = options.setChromeBinaryPath("path");
|
||||
options = options.setChromeLogFile("logfile");
|
||||
options = options.setLocalState("state");
|
||||
options = options.setLoggingPrefs(new webdriver.logging.Preferences());
|
||||
options = options.setProxy({ proxyType: "proxyType" });
|
||||
options = options.setUserPreferences("preferences");
|
||||
var capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
capabilities = options.toCapabilities(webdriver.Capabilities.chrome());
|
||||
var values: chrome.IOptionsValues = options.toJSON();
|
||||
}
|
||||
|
||||
function TestServiceBuilder() {
|
||||
var builder: chrome.ServiceBuilder = new chrome.ServiceBuilder();
|
||||
builder = new chrome.ServiceBuilder("exe");
|
||||
|
||||
var anything: any = builder.build();
|
||||
builder = builder.enableVerboseLogging();
|
||||
builder = builder.loggingTo("path");
|
||||
builder = builder.setNumHttpThreads(5);
|
||||
builder = builder.setStdio("config");
|
||||
builder = builder.setStdio(["A", "B"]);
|
||||
builder = builder.setUrlBasePath("path");
|
||||
builder = builder.usingPort(8080);
|
||||
builder = builder.withEnvironment({ "A": "a", "B": "b" });
|
||||
}
|
||||
|
||||
function TestChromeModule() {
|
||||
var service: any = chrome.getDefaultService();
|
||||
chrome.setDefaultService({});
|
||||
}
|
||||
|
||||
function TestBinary() {
|
||||
var binary: firefox.Binary = new firefox.Binary();
|
||||
binary = new firefox.Binary("exe");
|
||||
|
||||
binary.addArguments("A", "B", "C");
|
||||
var promise: webdriver.promise.Promise<void> = binary.kill();
|
||||
binary.launch("profile").then(function (result: any) { });
|
||||
}
|
||||
|
||||
function TestFirefoxDriver() {
|
||||
var driver: firefox.Driver = new firefox.Driver();
|
||||
driver = new chrome.Driver(webdriver.Capabilities.firefox());
|
||||
driver = new chrome.Driver(webdriver.Capabilities.firefox(), new webdriver.promise.ControlFlow());
|
||||
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
}
|
||||
|
||||
function TestFirefoxOptions() {
|
||||
var options: firefox.Options = new firefox.Options();
|
||||
|
||||
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" });
|
||||
var capabilities: webdriver.Capabilities = options.toCapabilities();
|
||||
var capabilities: webdriver.Capabilities = options.toCapabilities({});
|
||||
}
|
||||
|
||||
function TestFirefoxProfile() {
|
||||
var profile: firefox.Profile = new firefox.Profile();
|
||||
profile = new firefox.Profile("dir");
|
||||
|
||||
var bool: boolean = profile.acceptUntrustedCerts();
|
||||
profile.addExtension("ext");
|
||||
bool = profile.assumeUntrustedCertIssuer();
|
||||
profile.encode().then(function (prof: string) { });
|
||||
var num: number = profile.getPort();
|
||||
var 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);
|
||||
var stringPromise: webdriver.promise.Promise<string> = profile.writeToDisk();
|
||||
stringPromise = profile.writeToDisk(true);
|
||||
}
|
||||
|
||||
function TestExecutors() {
|
||||
var exec: webdriver.CommandExecutor = executors.createExecutor("url");
|
||||
exec = executors.createExecutor(new webdriver.promise.Promise<string>());
|
||||
}
|
||||
|
||||
function TestBuilder() {
|
||||
var builder: webdriver.Builder = new webdriver.Builder();
|
||||
|
||||
524
selenium-webdriver/selenium-webdriver.d.ts
vendored
524
selenium-webdriver/selenium-webdriver.d.ts
vendored
@@ -3,8 +3,516 @@
|
||||
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="chrome.d.ts" />
|
||||
/// <reference path="firefox.d.ts" />
|
||||
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: 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 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): void;
|
||||
}
|
||||
|
||||
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[]): 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>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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): 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>;
|
||||
}
|
||||
}
|
||||
|
||||
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 webdriver {
|
||||
|
||||
@@ -4219,6 +4727,18 @@ declare module webdriver {
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'selenium-webdriver/chrome' {
|
||||
export = chrome;
|
||||
}
|
||||
|
||||
declare module 'selenium-webdriver/firefox' {
|
||||
export = firefox;
|
||||
}
|
||||
|
||||
declare module 'selenium-webdriver/executors' {
|
||||
export = executors;
|
||||
}
|
||||
|
||||
declare module 'selenium-webdriver' {
|
||||
export = webdriver;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user