mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Updated Angular-Protractor to v1.5.0.
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
/// <reference path="angular-protractor.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 button: number = protractor.Button.LEFT;
|
||||
|
||||
var key: string = protractor.Key.ADD;
|
||||
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
|
||||
@@ -18,12 +14,6 @@ function TestWebDriverExports() {
|
||||
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();
|
||||
@@ -42,71 +32,25 @@ function TestWebDriverExports() {
|
||||
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 locator: webdriver.Locator = by.id('abc');
|
||||
|
||||
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
|
||||
var baseSession: webdriver.Session = session;
|
||||
|
||||
locator = protractor.By.name('name');
|
||||
|
||||
// logging module
|
||||
var driver: protractor.WebDriver = new protractor.WebDriver(session, <webdriver.CommandExecutor><any>{});
|
||||
driver = new protractor.WebDriver(session, <webdriver.CommandExecutor><any>{}, new webdriver.promise.ControlFlow());
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
|
||||
var levelName: string = protractor.logging.LevelName.ALL;
|
||||
var loggingType: string = protractor.logging.Type.CLIENT;
|
||||
var webElement: protractor.WebElement = new protractor.WebElement(driver, { ELEMENT: 'abc' });
|
||||
var baseWebElement: webdriver.WebElement = webElement;
|
||||
|
||||
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; });
|
||||
var webElementPromise: protractor.WebElementPromise = new protractor.WebElementPromise(driver, { ELEMENT: 'abc' });
|
||||
var baseWebElementPromise: webdriver.WebElementPromise = webElementPromise;
|
||||
|
||||
// error module
|
||||
|
||||
@@ -114,17 +58,140 @@ function TestWebDriverExports() {
|
||||
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
|
||||
// process module
|
||||
// logging module
|
||||
|
||||
var isNative: boolean = protractor.process.isNative();
|
||||
var value: string;
|
||||
var levelName: string = protractor.logging.Level.ALL.name;
|
||||
var loggingType: string = protractor.logging.Type.CLIENT;
|
||||
|
||||
value = protractor.process.getEnv('name');
|
||||
value = protractor.process.getEnv('name', 'default');
|
||||
var level: webdriver.logging.ILevel = protractor.logging.Level.ALL;
|
||||
|
||||
protractor.process.setEnv('name', 'value');
|
||||
protractor.process.setEnv('name', 123);
|
||||
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');
|
||||
|
||||
var prefs: protractor.logging.Preferences = new protractor.logging.Preferences();
|
||||
|
||||
// promise module
|
||||
|
||||
var cancelError: protractor.promise.CancellationError = new protractor.promise.CancellationError();
|
||||
cancelError = new protractor.promise.CancellationError('message');
|
||||
var baseCancelError: webdriver.promise.CancellationError = cancelError;
|
||||
|
||||
var thenable: protractor.promise.Thenable<any> = new protractor.promise.Thenable();
|
||||
var baseThenable: webdriver.promise.Thenable<any> = thenable;
|
||||
|
||||
var promise: protractor.promise.Promise<any> = new protractor.promise.Promise();
|
||||
var basePromise: webdriver.promise.Promise<any> = promise;
|
||||
|
||||
var deferred: protractor.promise.Deferred<any> = new protractor.promise.Deferred();
|
||||
var baseDeferred: webdriver.promise.Deferred<any> = deferred;
|
||||
|
||||
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
|
||||
var baseFlow: webdriver.promise.ControlFlow = flow;
|
||||
|
||||
var arrayPromise: protractor.promise.Promise<any[]> = protractor.promise.all([new protractor.promise.Promise<number>(), new protractor.promise.Promise<string>()]);
|
||||
|
||||
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; });
|
||||
|
||||
promise = protractor.promise.consume(function () {
|
||||
return 5;
|
||||
});
|
||||
promise = protractor.promise.consume(function () {
|
||||
return 5;
|
||||
}, this);
|
||||
promise = protractor.promise.consume(function () {
|
||||
return 5;
|
||||
}, this, 1, 2, 3);
|
||||
|
||||
flow = protractor.promise.controlFlow();
|
||||
|
||||
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
|
||||
|
||||
deferred = protractor.promise.defer();
|
||||
|
||||
promise = protractor.promise.delayed(123);
|
||||
|
||||
var numbersPromise: protractor.promise.Promise<number[]> = protractor.promise.filter([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.filter([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = protractor.promise.filter(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.filter(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
numbersPromise = protractor.promise.map([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.map([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = protractor.promise.map(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.map(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
promise = protractor.promise.fulfilled();
|
||||
promise = protractor.promise.fulfilled({a: 123});
|
||||
|
||||
promise = protractor.promise.fullyResolved({a: 123});
|
||||
|
||||
var bool: boolean = protractor.promise.isGenerator(function () { });
|
||||
var bool: 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; });
|
||||
|
||||
// stacktrace module
|
||||
bool = protractor.stacktrace.BROWSER_SUPPORTED;
|
||||
|
||||
var frame: protractor.stacktrace.Frame = new protractor.stacktrace.Frame();
|
||||
var baseFrame: webdriver.stacktrace.Frame = frame;
|
||||
|
||||
var snapshot: protractor.stacktrace.Snapshot = new protractor.stacktrace.Snapshot();
|
||||
var baseSnapshot: webdriver.stacktrace.Snapshot = snapshot;
|
||||
|
||||
var err: Error = protractor.stacktrace.format(new Error("Error"));
|
||||
var frames: protractor.stacktrace.Frame[] = protractor.stacktrace.get();
|
||||
|
||||
// until module
|
||||
var conditionB: protractor.until.Condition<boolean> = new protractor.until.Condition<boolean>('message', function (driver: webdriver.WebDriver) { return true; });
|
||||
var conditionBBase: webdriver.until.Condition<boolean> = conditionB;
|
||||
var conditionWebElement: protractor.until.Condition<webdriver.IWebElement>;
|
||||
var conditionWebElements: protractor.until.Condition<webdriver.IWebElement[]>;
|
||||
|
||||
conditionB = protractor.until.ableToSwitchToFrame(5);
|
||||
var conditionAlert: protractor.until.Condition<webdriver.Alert> = protractor.until.alertIsPresent();
|
||||
var el: protractor.ElementFinder = element(by.id('id'));
|
||||
conditionB = protractor.until.elementIsDisabled(el);
|
||||
conditionB = protractor.until.elementIsEnabled(el);
|
||||
conditionB = protractor.until.elementIsNotSelected(el);
|
||||
conditionB = protractor.until.elementIsNotVisible(el);
|
||||
conditionB = protractor.until.elementIsSelected(el);
|
||||
conditionB = protractor.until.elementIsVisible(el);
|
||||
conditionB = protractor.until.elementTextContains(el, 'text');
|
||||
conditionB = protractor.until.elementTextIs(el, 'text');
|
||||
conditionB = protractor.until.elementTextMatches(el, /text/);
|
||||
conditionB = protractor.until.stalenessOf(el);
|
||||
conditionB = protractor.until.titleContains('text');
|
||||
conditionB = protractor.until.titleIs('text');
|
||||
conditionB = protractor.until.titleMatches(/text/);
|
||||
|
||||
conditionWebElement = protractor.until.elementLocated(by.id('id'));
|
||||
conditionWebElements = protractor.until.elementsLocated(by.className('class'));
|
||||
}
|
||||
|
||||
function TestProtractor() {
|
||||
@@ -133,31 +200,47 @@ function TestProtractor() {
|
||||
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;
|
||||
|
||||
var actions: protractor.ActionSequence = ptor.actions();
|
||||
|
||||
var promise: protractor.promise.Promise<any> = ptor.call(function () { });
|
||||
var promise: protractor.promise.Promise<any> = ptor.call(function () { }, this);
|
||||
var promise: protractor.promise.Promise<any> = ptor.call(function (a: number, b: number, c:number) { }, this, 1, 2,3);
|
||||
|
||||
promise = ptor.executeAsyncScript('SomeScript');
|
||||
promise = ptor.executeAsyncScript('SomeScript', 1, 2, 3);
|
||||
promise = ptor.executeAsyncScript(function () { });
|
||||
promise = ptor.executeAsyncScript(function (a: number, b: number, c: number) { }, 1, 2, 3);
|
||||
|
||||
promise = ptor.executeScript('SomeScript');
|
||||
promise = ptor.executeScript('SomeScript', 1, 2, 3);
|
||||
promise = ptor.executeScript(function () { });
|
||||
promise = ptor.executeScript(function (a: number, b: number, c: number) { }, 1, 2, 3);
|
||||
|
||||
ptor = browser.forkNewDriverInstance();
|
||||
ptor = browser.forkNewDriverInstance(true);
|
||||
ptor = browser.forkNewDriverInstance(true, false);
|
||||
|
||||
driver = ptor.driver;
|
||||
var baseUrl: string = ptor.baseUrl;
|
||||
var rootEl: string = ptor.rootEl;
|
||||
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
|
||||
var params: any = ptor.params;
|
||||
ptor.resetUrl = "url";
|
||||
|
||||
ptor.debugger();
|
||||
ptor.close();
|
||||
var controlFlow: protractor.promise.ControlFlow = ptor.controlFlow();
|
||||
|
||||
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.findElements(by.css('.class')).then(function (elements: webdriver.WebElement[]) { });
|
||||
ptor.isElementPresent(by.css('.class')).then(function (present: boolean) { });
|
||||
ptor.isElementPresent(webElement).then(function (present: boolean) { });
|
||||
|
||||
ptor.clearMockModules();
|
||||
ptor.addMockModule('name', 'script');
|
||||
@@ -173,16 +256,43 @@ function TestProtractor() {
|
||||
|
||||
elementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
|
||||
var locationAbsUrl: webdriver.promise.Promise<string> = ptor.getLocationAbsUrl();
|
||||
ptor.setLocation('webaddress.com');
|
||||
|
||||
promise = ptor.get('webaddress.com');
|
||||
promise = ptor.get('webdaddress.com', 45);
|
||||
var voidPromise: webdriver.promise.Promise<void> = ptor.get('webaddress.com');
|
||||
voidPromise = ptor.get('webdaddress.com', 45);
|
||||
voidPromise = ptor.quit();
|
||||
voidPromise = ptor.sleep(5000);
|
||||
|
||||
ptor.refresh();
|
||||
ptor.refresh(45);
|
||||
var navigation: webdriver.WebDriverNavigation = ptor.navigate();
|
||||
ptor.pause();
|
||||
ptor.pause(8080);
|
||||
|
||||
ptor.getAllWindowHandles().then(function (handles: string[]) { });
|
||||
|
||||
var capabilities: protractor.promise.Promise<protractor.Capabilities> = ptor.getCapabilities();
|
||||
|
||||
var stringPromise: webdriver.promise.Promise<string>;
|
||||
stringPromise = ptor.getCurrentUrl();
|
||||
stringPromise = ptor.getPageSource();
|
||||
stringPromise = ptor.getTitle();
|
||||
stringPromise = ptor.getWindowHandle();
|
||||
stringPromise = ptor.takeScreenshot();
|
||||
|
||||
ptor.getPageTimeout = 5000;
|
||||
|
||||
var session: protractor.promise.Promise<protractor.Session> = ptor.getSession();
|
||||
|
||||
var options: webdriver.WebDriverOptions = ptor.manage();
|
||||
|
||||
promise = ptor.schedule(new protractor.Command(protractor.CommandName.ACCEPT_ALERT), 'asdf');
|
||||
|
||||
var targetLocator: webdriver.WebDriverTargetLocator = ptor.switchTo();
|
||||
|
||||
ptor.wait(protractor.until.elementLocated(by.id('id')), 5000).then(function (el: webdriver.IWebElement) { });;
|
||||
ptor.wait(protractor.until.elementLocated(by.id('id')), 5000, 'message').then(function (el: webdriver.IWebElement) { });;
|
||||
}
|
||||
|
||||
function TestElement() {
|
||||
@@ -192,80 +302,121 @@ function TestElement() {
|
||||
|
||||
function TestElementFinder() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
var voidPromise: webdriver.promise.Promise<void>;
|
||||
var stringPromise: webdriver.promise.Promise<string>;
|
||||
var booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
|
||||
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();
|
||||
elementFinder.getId().then(function (id: webdriver.IWebElementId) { });
|
||||
voidPromise = elementFinder.click();
|
||||
elementFinder = elementFinder.allowAnimations('string');
|
||||
voidPromise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
stringPromise = elementFinder.getTagName();
|
||||
stringPromise = elementFinder.getCssValue('display');
|
||||
stringPromise = elementFinder.getAttribute('atribute');
|
||||
stringPromise = elementFinder.getText();
|
||||
elementFinder.getSize().then(function (size: webdriver.ISize) { });
|
||||
elementFinder.getLocation().then(function (location: webdriver.ILocation) { });
|
||||
booleanPromise = elementFinder.isEnabled();
|
||||
booleanPromise = elementFinder.isSelected();
|
||||
voidPromise = elementFinder.submit();
|
||||
voidPromise = elementFinder.clear();
|
||||
booleanPromise = elementFinder.isDisplayed();
|
||||
stringPromise = elementFinder.getOuterHtml();
|
||||
stringPromise = elementFinder.getInnerHtml();
|
||||
booleanPromise = elementFinder.isElementPresent(by.id('id'));
|
||||
elementFinder = elementFinder.$('.class');
|
||||
var finders: protractor.ElementArrayFinder = elementFinder.$$('.class');
|
||||
elementFinder = elementFinder.evaluate('expression');
|
||||
booleanPromise = elementFinder.isPresent();
|
||||
|
||||
var webElement: webdriver.WebElement;
|
||||
var webElement: webdriver.WebElement = elementFinder.getWebElement();
|
||||
finders = elementFinder.all(by.className('class'));
|
||||
elementFinder = elementFinder.allowAnimations('abc');
|
||||
elementFinder = elementFinder.clone();
|
||||
elementFinder = elementFinder.element(by.id('id'));
|
||||
|
||||
var b: boolean = elementFinder.isPending();
|
||||
var locator: webdriver.Locator = elementFinder.locator();
|
||||
}
|
||||
|
||||
function TestElementArrayFinder() {
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
|
||||
var voidPromise: webdriver.promise.Promise<void>;
|
||||
var stringPromise: webdriver.promise.Promise<string[]>;
|
||||
var booleanPromise: webdriver.promise.Promise<boolean[]>;
|
||||
|
||||
elementArrayFinder.getId().then(function (id: webdriver.IWebElementId[]) { });
|
||||
voidPromise = elementArrayFinder.click();
|
||||
elementArrayFinder = elementArrayFinder.allowAnimations(true);
|
||||
voidPromise = elementArrayFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
stringPromise = elementArrayFinder.getTagName();
|
||||
stringPromise = elementArrayFinder.getCssValue('display');
|
||||
stringPromise = elementArrayFinder.getAttribute('atribute');
|
||||
stringPromise = elementArrayFinder.getText();
|
||||
elementArrayFinder.getSize().then(function (size: webdriver.ISize[]) { });
|
||||
elementArrayFinder.getLocation().then(function (location: webdriver.ILocation[]) { });
|
||||
booleanPromise = elementArrayFinder.isEnabled();
|
||||
booleanPromise = elementArrayFinder.isSelected();
|
||||
voidPromise = elementArrayFinder.submit();
|
||||
voidPromise = elementArrayFinder.clear();
|
||||
booleanPromise = elementArrayFinder.isDisplayed();
|
||||
stringPromise = elementArrayFinder.getOuterHtml();
|
||||
stringPromise = elementArrayFinder.getInnerHtml();
|
||||
var finders: protractor.ElementArrayFinder = elementArrayFinder.$$('.class');
|
||||
elementArrayFinder = elementArrayFinder.evaluate('expression');
|
||||
|
||||
finders = elementArrayFinder.all(by.className('class'));
|
||||
elementArrayFinder = elementArrayFinder.clone();
|
||||
|
||||
var b: boolean = elementArrayFinder.isPending();
|
||||
var locator: webdriver.Locator = elementArrayFinder.locator();
|
||||
|
||||
var findersArray: protractor.ElementFinder[] = elementArrayFinder.asElementFinders_();
|
||||
|
||||
var driverElementArray: webdriver.WebElement[] = elementArrayFinder.getWebElements();
|
||||
elementFinder = elementArrayFinder.get(42);
|
||||
var elementFinder: protractor.ElementFinder = elementArrayFinder.get(42);
|
||||
elementFinder = elementArrayFinder.first();
|
||||
elementFinder = elementArrayFinder.last();
|
||||
promise = elementArrayFinder.count();
|
||||
promise = elementArrayFinder.asElementFinders_();
|
||||
elementFinder = elementArrayFinder.toElementFinder_()
|
||||
var numberPromise: protractor.promise.Promise<number> = elementArrayFinder.count();
|
||||
elementArrayFinder.each(function(element: protractor.ElementFinder){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
|
||||
stringPromise = elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
|
||||
return 'abc';
|
||||
})
|
||||
elementArrayFinder = 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){
|
||||
elementArrayFinder.reduce(function (accumulator: string, element: protractor.ElementFinder) {
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
}, '').then(function (result: string) { });
|
||||
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder, index: number, array: protractor.ElementFinder[]){
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
}, '').then(function (result: string) { });
|
||||
elementArrayFinder.then(function(underlyingElementFinders: protractor.ElementFinder[]){
|
||||
//nothing
|
||||
});
|
||||
}
|
||||
|
||||
// This function tests the angular specific locator strategies.
|
||||
// This function tests the locator strategies.
|
||||
function TestLocatorStrategies() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
var ptor: protractor.Protractor = browser;
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
// Protractor Specific Locators
|
||||
protractor.By.addLocator('customLocator', 'script');
|
||||
protractor.By.addLocator('customLocator2', function(){
|
||||
// nothing
|
||||
});
|
||||
|
||||
// Angular specific locators.
|
||||
webElement = ptor.findElement(protractor.By.binding('binding'));
|
||||
webElement = ptor.findElement(protractor.By.exactBinding('exactBinding'));
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
@@ -277,4 +428,23 @@ function TestLocatorStrategies() {
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
webElement = ptor.findElement(protractor.By.cssContainingText('cssSelector', 'search text'));
|
||||
webElement = ptor.findElement(protractor.By.options('options'));
|
||||
// One standard locator for good measure.
|
||||
webElement = ptor.findElement(protractor.By.id('id'));
|
||||
|
||||
var el: protractor.ElementFinder;
|
||||
|
||||
// Angular specific locators.
|
||||
el = element(by.binding('binding'));
|
||||
el = element(by.exactBinding('exactBinding'));
|
||||
el = element(by.model('model'));
|
||||
el = element(by.repeater('repeater'));
|
||||
el = element(by.repeater('repeater').column(0));
|
||||
el = element(by.repeater('repeater').row(0));
|
||||
el = element(by.repeater('repeater').row(0).column(0));
|
||||
el = element(by.buttonText('buttonText'));
|
||||
el = element(by.partialButtonText('partialButtonText'));
|
||||
el = element(by.cssContainingText('cssSelector', 'search text'));
|
||||
el = element(by.options('options'));
|
||||
// One standard locator for good measure.
|
||||
el = element(by.id('id'));
|
||||
}
|
||||
|
||||
+1146
-491
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,280 @@
|
||||
/// <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
Vendored
+2
-2
@@ -65,7 +65,7 @@
|
||||
* extensions to add.
|
||||
* @return {!Options} A self reference.
|
||||
*/
|
||||
addExtensions(...var_args): Options;
|
||||
addExtensions(...var_args: any[]): Options;
|
||||
|
||||
|
||||
/**
|
||||
@@ -261,7 +261,7 @@
|
||||
* @param {!remote.DriverService} service The service to use.
|
||||
* @throws {Error} If the default service is currently running.
|
||||
*/
|
||||
function setDefaultService(service: any);
|
||||
function setDefaultService(service: any): void;
|
||||
}
|
||||
|
||||
declare module 'selenium-webdriver/chrome' {
|
||||
|
||||
Vendored
+9
-9
@@ -15,7 +15,7 @@
|
||||
* @param {...(string|!Array.<string>)} var_args Either the arguments to add as
|
||||
* varargs, or the arguments as an array.
|
||||
*/
|
||||
addArguments(...var_args: string[]);
|
||||
addArguments(...var_args: string[]): void;
|
||||
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@
|
||||
* @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);
|
||||
addExtension(extension: string): void;
|
||||
|
||||
|
||||
/**
|
||||
@@ -139,9 +139,9 @@
|
||||
* @param {(string|number|boolean)} value The preference value.
|
||||
* @throws {Error} If attempting to set a frozen preference.
|
||||
*/
|
||||
setPreference(key: string, value: string);
|
||||
setPreference(key: string, value: number);
|
||||
setPreference(key: string, value: boolean);
|
||||
setPreference(key: string, value: string): void;
|
||||
setPreference(key: string, value: number): void;
|
||||
setPreference(key: string, value: boolean): void;
|
||||
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@
|
||||
* 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);
|
||||
setPort(port: number): void;
|
||||
|
||||
|
||||
/**
|
||||
@@ -182,14 +182,14 @@
|
||||
* certificates.
|
||||
* @param {boolean} value .
|
||||
*/
|
||||
setAcceptUntrustedCerts(value: boolean);
|
||||
setAcceptUntrustedCerts(value: boolean): void;
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether to assume untrusted certificates come from untrusted issuers.
|
||||
* @param {boolean} value .
|
||||
*/
|
||||
setAssumeUntrustedCertIssuer(value: boolean);
|
||||
setAssumeUntrustedCertIssuer(value: boolean): void;
|
||||
|
||||
|
||||
/**
|
||||
@@ -203,7 +203,7 @@
|
||||
* Sets whether to use native events with this profile.
|
||||
* @param {boolean} enabled .
|
||||
*/
|
||||
setNativeEventsEnabled(enabled: boolean);
|
||||
setNativeEventsEnabled(enabled: boolean): void;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/// <reference path="selenium-webdriver.d.ts" />
|
||||
/// <reference path="selenium-webdriver-2.39.0.d.ts" />
|
||||
|
||||
function TestAbstractBuilder() {
|
||||
var builder: webdriver.AbstractBuilder = new webdriver.AbstractBuilder();
|
||||
@@ -658,7 +658,10 @@ function TestWebElement() {
|
||||
}
|
||||
|
||||
function TestLogging() {
|
||||
webdriver.logging.Preferences['name'] = 'ABC';
|
||||
var preferences: webdriver.logging.Preferences = new webdriver.logging.Preferences();
|
||||
preferences.setLevel(webdriver.logging.Type.BROWSER, webdriver.logging.Level.ALL);
|
||||
var prefs: any = preferences.toJSON();
|
||||
|
||||
var level: webdriver.logging.ILevel = webdriver.logging.getLevel('OFF');
|
||||
level = webdriver.logging.getLevel(1);
|
||||
|
||||
|
||||
+547
-265
@@ -182,7 +182,7 @@ declare module webdriver {
|
||||
name: string;
|
||||
}
|
||||
|
||||
var Level: {
|
||||
interface ILevelValues {
|
||||
ALL: ILevel;
|
||||
DEBUG: ILevel;
|
||||
INFO: ILevel;
|
||||
@@ -191,6 +191,8 @@ declare module webdriver {
|
||||
OFF: ILevel;
|
||||
}
|
||||
|
||||
var Level: ILevelValues;
|
||||
|
||||
/**
|
||||
* Converts a level name or value to a {@link webdriver.logging.Level} value.
|
||||
* If the name/value is not recognized, {@link webdriver.logging.Level.ALL}
|
||||
@@ -272,6 +274,262 @@ declare module webdriver {
|
||||
}
|
||||
|
||||
module promise {
|
||||
//region Functions
|
||||
|
||||
/**
|
||||
* Given an array of promises, will return a promise that will be fulfilled
|
||||
* with the fulfillment values of the input array's values. If any of the
|
||||
* input array's promises are rejected, the returned promise will be rejected
|
||||
* with the same reason.
|
||||
*
|
||||
* @param {!Array.<(T|!webdriver.promise.Promise.<T>)>} arr An array of
|
||||
* promises to wait on.
|
||||
* @return {!webdriver.promise.Promise.<!Array.<T>>} A promise that is
|
||||
* fulfilled with an array containing the fulfilled values of the
|
||||
* input array, or rejected with the same reason as the first
|
||||
* rejected value.
|
||||
* @template T
|
||||
*/
|
||||
function all(arr: Promise<any>[]): Promise<any[]>;
|
||||
|
||||
/**
|
||||
* Invokes the appropriate callback function as soon as a promised
|
||||
* {@code value} is resolved. This function is similar to
|
||||
* {@link 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: Function, opt_errback?: Function): void;
|
||||
|
||||
/**
|
||||
* @return {!webdriver.promise.ControlFlow} The currently active control flow.
|
||||
*/
|
||||
function controlFlow(): 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<R>(callback: (flow: ControlFlow) => R): Promise<R>;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Tests is a function is a generator.
|
||||
* @param {!Function} fn The function to test.
|
||||
* @return {boolean} Whether the function is a generator.
|
||||
*/
|
||||
function isGenerator(fn: Function): 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): Promise<void>;
|
||||
|
||||
/**
|
||||
* Calls a function for each element in an array, and if the function returns
|
||||
* true adds the element to a new array.
|
||||
*
|
||||
* <p>If the return value of the filter function is a promise, this function
|
||||
* will wait for it to be fulfilled before determining whether to insert the
|
||||
* element into the new array.
|
||||
*
|
||||
* <p>If the filter function throws or returns a rejected promise, the promise
|
||||
* returned by this function will be rejected with the same reason. Only the
|
||||
* first failure will be reported; all subsequent errors will be silently
|
||||
* ignored.
|
||||
*
|
||||
* @param {!(Array.<TYPE>|webdriver.promise.Promise.<!Array.<TYPE>>)} arr The
|
||||
* array to iterator over, or a promise that will resolve to said array.
|
||||
* @param {function(this: SELF, TYPE, number, !Array.<TYPE>): (
|
||||
* boolean|webdriver.promise.Promise.<boolean>)} fn The function
|
||||
* to call for each element in the array.
|
||||
* @param {SELF=} opt_self The object to be used as the value of 'this' within
|
||||
* {@code fn}.
|
||||
* @template TYPE, SELF
|
||||
*/
|
||||
function filter<T>(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>;
|
||||
function filter<T>(arr: Promise<T[]>, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>
|
||||
|
||||
/**
|
||||
* Creates a new deferred object.
|
||||
* @return {!webdriver.promise.Deferred} The new deferred object.
|
||||
*/
|
||||
function defer<T>(): Deferred<T>;
|
||||
|
||||
/**
|
||||
* 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<T>(opt_value?: T): Promise<T>;
|
||||
|
||||
/**
|
||||
* Calls a function for each element in an array and inserts the result into a
|
||||
* new array, which is used as the fulfillment value of the promise returned
|
||||
* by this function.
|
||||
*
|
||||
* <p>If the return value of the mapping function is a promise, this function
|
||||
* will wait for it to be fulfilled before inserting it into the new array.
|
||||
*
|
||||
* <p>If the mapping function throws or returns a rejected promise, the
|
||||
* promise returned by this function will be rejected with the same reason.
|
||||
* Only the first failure will be reported; all subsequent errors will be
|
||||
* silently ignored.
|
||||
*
|
||||
* @param {!(Array.<TYPE>|webdriver.promise.Promise.<!Array.<TYPE>>)} arr The
|
||||
* array to iterator over, or a promise that will resolve to said array.
|
||||
* @param {function(this: SELF, TYPE, number, !Array.<TYPE>): ?} fn The
|
||||
* function to call for each element in the array. This function should
|
||||
* expect three arguments (the element, the index, and the array itself.
|
||||
* @param {SELF=} opt_self The object to be used as the value of 'this' within
|
||||
* {@code fn}.
|
||||
* @template TYPE, SELF
|
||||
*/
|
||||
function map<T>(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>
|
||||
function map<T>(arr: Promise<T[]>, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>
|
||||
|
||||
/**
|
||||
* 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): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<T>(fn: Function, ...var_args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Consumes a {@code GeneratorFunction}. Each time the generator yields a
|
||||
* promise, this function will wait for it to be fulfilled before feeding the
|
||||
* fulfilled value back into {@code next}. Likewise, if a yielded promise is
|
||||
* rejected, the rejection error will be passed to {@code throw}.
|
||||
*
|
||||
* <p>Example 1: the Fibonacci Sequence.
|
||||
* <pre><code>
|
||||
* webdriver.promise.consume(function* fibonacci() {
|
||||
* var n1 = 1, n2 = 1;
|
||||
* for (var i = 0; i < 4; ++i) {
|
||||
* var tmp = yield n1 + n2;
|
||||
* n1 = n2;
|
||||
* n2 = tmp;
|
||||
* }
|
||||
* return n1 + n2;
|
||||
* }).then(function(result) {
|
||||
* console.log(result); // 13
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
* <p>Example 2: a generator that throws.
|
||||
* <pre><code>
|
||||
* webdriver.promise.consume(function* () {
|
||||
* yield webdriver.promise.delayed(250).then(function() {
|
||||
* throw Error('boom');
|
||||
* });
|
||||
* }).thenCatch(function(e) {
|
||||
* console.log(e.toString()); // Error: boom
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
* @param {!Function} generatorFn The generator function to execute.
|
||||
* @param {Object=} opt_self The object to use as "this" when invoking the
|
||||
* initial generator.
|
||||
* @param {...*} var_args Any arguments to pass to the initial generator.
|
||||
* @return {!webdriver.promise.Promise.<?>} A promise that will resolve to the
|
||||
* generator's final result.
|
||||
* @throws {TypeError} If the given function is not a generator.
|
||||
*/
|
||||
function consume<T>(generatorFn: Function, opt_self?: any, ...var_args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* 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<T,R>(value: T, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): Promise<R>;
|
||||
function when<T,R>(value: Promise<T>, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): Promise<R>;
|
||||
|
||||
/**
|
||||
* 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<T>(value: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* 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: ControlFlow): void;
|
||||
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* Error used when the computation of a promise is cancelled.
|
||||
*
|
||||
* @extends {goog.debug.Error}
|
||||
* @final
|
||||
*/
|
||||
class CancellationError {
|
||||
/**
|
||||
* @param {string=} opt_msg The cancellation message.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(opt_msg?: string);
|
||||
|
||||
name: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface IThenable<T> {
|
||||
/**
|
||||
* Cancels the computation of this promise's value, rejecting the promise in the
|
||||
@@ -497,245 +755,6 @@ declare module webdriver {
|
||||
static isImplementation(object: any): boolean;
|
||||
}
|
||||
|
||||
//region Functions
|
||||
|
||||
/**
|
||||
* Given an array of promises, will return a promise that will be fulfilled
|
||||
* with the fulfillment values of the input array's values. If any of the
|
||||
* input array's promises are rejected, the returned promise will be rejected
|
||||
* with the same reason.
|
||||
*
|
||||
* @param {!Array.<(T|!webdriver.promise.Promise.<T>)>} arr An array of
|
||||
* promises to wait on.
|
||||
* @return {!webdriver.promise.Promise.<!Array.<T>>} A promise that is
|
||||
* fulfilled with an array containing the fulfilled values of the
|
||||
* input array, or rejected with the same reason as the first
|
||||
* rejected value.
|
||||
* @template T
|
||||
*/
|
||||
function all(arr: Promise<any>[]): Promise<any[]>;
|
||||
|
||||
/**
|
||||
* Invokes the appropriate callback function as soon as a promised
|
||||
* {@code value} is resolved. This function is similar to
|
||||
* {@link 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: Function, opt_errback?: Function): void;
|
||||
|
||||
/**
|
||||
* @return {!webdriver.promise.ControlFlow} The currently active control flow.
|
||||
*/
|
||||
function controlFlow(): 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<R>(callback: (flow: ControlFlow) => R): Promise<R>;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Tests is a function is a generator.
|
||||
* @param {!Function} fn The function to test.
|
||||
* @return {boolean} Whether the function is a generator.
|
||||
*/
|
||||
function isGenerator(fn: Function): 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): Promise<void>;
|
||||
|
||||
/**
|
||||
* Calls a function for each element in an array, and if the function returns
|
||||
* true adds the element to a new array.
|
||||
*
|
||||
* <p>If the return value of the filter function is a promise, this function
|
||||
* will wait for it to be fulfilled before determining whether to insert the
|
||||
* element into the new array.
|
||||
*
|
||||
* <p>If the filter function throws or returns a rejected promise, the promise
|
||||
* returned by this function will be rejected with the same reason. Only the
|
||||
* first failure will be reported; all subsequent errors will be silently
|
||||
* ignored.
|
||||
*
|
||||
* @param {!(Array.<TYPE>|webdriver.promise.Promise.<!Array.<TYPE>>)} arr The
|
||||
* array to iterator over, or a promise that will resolve to said array.
|
||||
* @param {function(this: SELF, TYPE, number, !Array.<TYPE>): (
|
||||
* boolean|webdriver.promise.Promise.<boolean>)} fn The function
|
||||
* to call for each element in the array.
|
||||
* @param {SELF=} opt_self The object to be used as the value of 'this' within
|
||||
* {@code fn}.
|
||||
* @template TYPE, SELF
|
||||
*/
|
||||
function filter<T>(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>;
|
||||
function filter<T>(arr: Promise<T[]>, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>
|
||||
|
||||
/**
|
||||
* Creates a new deferred object.
|
||||
* @return {!webdriver.promise.Deferred} The new deferred object.
|
||||
*/
|
||||
function defer<T>(): Deferred<T>;
|
||||
|
||||
/**
|
||||
* 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<T>(opt_value?: T): Promise<T>;
|
||||
|
||||
/**
|
||||
* Calls a function for each element in an array and inserts the result into a
|
||||
* new array, which is used as the fulfillment value of the promise returned
|
||||
* by this function.
|
||||
*
|
||||
* <p>If the return value of the mapping function is a promise, this function
|
||||
* will wait for it to be fulfilled before inserting it into the new array.
|
||||
*
|
||||
* <p>If the mapping function throws or returns a rejected promise, the
|
||||
* promise returned by this function will be rejected with the same reason.
|
||||
* Only the first failure will be reported; all subsequent errors will be
|
||||
* silently ignored.
|
||||
*
|
||||
* @param {!(Array.<TYPE>|webdriver.promise.Promise.<!Array.<TYPE>>)} arr The
|
||||
* array to iterator over, or a promise that will resolve to said array.
|
||||
* @param {function(this: SELF, TYPE, number, !Array.<TYPE>): ?} fn The
|
||||
* function to call for each element in the array. This function should
|
||||
* expect three arguments (the element, the index, and the array itself.
|
||||
* @param {SELF=} opt_self The object to be used as the value of 'this' within
|
||||
* {@code fn}.
|
||||
* @template TYPE, SELF
|
||||
*/
|
||||
function map<T>(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>
|
||||
function map<T>(arr: Promise<T[]>, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): Promise<T[]>
|
||||
|
||||
/**
|
||||
* 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): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<T>(fn: Function, ...var_args): Promise<T>;
|
||||
|
||||
/**
|
||||
* Consumes a {@code GeneratorFunction}. Each time the generator yields a
|
||||
* promise, this function will wait for it to be fulfilled before feeding the
|
||||
* fulfilled value back into {@code next}. Likewise, if a yielded promise is
|
||||
* rejected, the rejection error will be passed to {@code throw}.
|
||||
*
|
||||
* <p>Example 1: the Fibonacci Sequence.
|
||||
* <pre><code>
|
||||
* webdriver.promise.consume(function* fibonacci() {
|
||||
* var n1 = 1, n2 = 1;
|
||||
* for (var i = 0; i < 4; ++i) {
|
||||
* var tmp = yield n1 + n2;
|
||||
* n1 = n2;
|
||||
* n2 = tmp;
|
||||
* }
|
||||
* return n1 + n2;
|
||||
* }).then(function(result) {
|
||||
* console.log(result); // 13
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
* <p>Example 2: a generator that throws.
|
||||
* <pre><code>
|
||||
* webdriver.promise.consume(function* () {
|
||||
* yield webdriver.promise.delayed(250).then(function() {
|
||||
* throw Error('boom');
|
||||
* });
|
||||
* }).thenCatch(function(e) {
|
||||
* console.log(e.toString()); // Error: boom
|
||||
* });
|
||||
* </code></pre>
|
||||
*
|
||||
* @param {!Function} generatorFn The generator function to execute.
|
||||
* @param {Object=} opt_self The object to use as "this" when invoking the
|
||||
* initial generator.
|
||||
* @param {...*} var_args Any arguments to pass to the initial generator.
|
||||
* @return {!webdriver.promise.Promise.<?>} A promise that will resolve to the
|
||||
* generator's final result.
|
||||
* @throws {TypeError} If the given function is not a generator.
|
||||
*/
|
||||
function consume<T>(generatorFn: Function, opt_self?: any, ...var_args): Promise<T>;
|
||||
|
||||
/**
|
||||
* 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<T,R>(value: T, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): Promise<R>;
|
||||
function when<T,R>(value: Promise<T>, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): Promise<R>;
|
||||
|
||||
/**
|
||||
* 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<T>(value: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* 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: ControlFlow): void;
|
||||
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* Represents the eventual value of a completed operation. Each promise may be
|
||||
* in one of three states: pending, resolved, or rejected. Each promise starts
|
||||
@@ -1273,9 +1292,9 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} A new condition.
|
||||
*/
|
||||
function ableToSwitchToFrame(frame: number): Condition<boolean>;
|
||||
function ableToSwitchToFrame(frame: WebElement): Condition<boolean>;
|
||||
function ableToSwitchToFrame(frame: IWebElement): Condition<boolean>;
|
||||
function ableToSwitchToFrame(frame: Locator): Condition<boolean>;
|
||||
function ableToSwitchToFrame(frame: (webdriver: WebDriver) => WebElement): Condition<boolean>;
|
||||
function ableToSwitchToFrame(frame: (webdriver: WebDriver) => IWebElement): Condition<boolean>;
|
||||
function ableToSwitchToFrame(frame: any): Condition<boolean>;
|
||||
|
||||
/**
|
||||
@@ -1293,7 +1312,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#isEnabled
|
||||
*/
|
||||
function elementIsDisabled(element: WebElement): Condition<boolean>;
|
||||
function elementIsDisabled(element: IWebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be enabled.
|
||||
@@ -1302,7 +1321,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#isEnabled
|
||||
*/
|
||||
function elementIsEnabled(element: WebElement): Condition<boolean>;
|
||||
function elementIsEnabled(element: IWebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be deselected.
|
||||
@@ -1311,7 +1330,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#isSelected
|
||||
*/
|
||||
function elementIsNotSelected(element: WebElement): Condition<boolean>;
|
||||
function elementIsNotSelected(element: IWebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be in the DOM,
|
||||
@@ -1321,7 +1340,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#isDisplayed
|
||||
*/
|
||||
function elementIsNotVisible(element: WebElement): Condition<boolean>;
|
||||
function elementIsNotVisible(element: IWebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to be selected.
|
||||
@@ -1329,7 +1348,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#isSelected
|
||||
*/
|
||||
function elementIsSelected(element: WebElement): Condition<boolean>;
|
||||
function elementIsSelected(element: IWebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to become visible.
|
||||
@@ -1338,7 +1357,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#isDisplayed
|
||||
*/
|
||||
function elementIsVisible(element: WebElement): Condition<boolean>;
|
||||
function elementIsVisible(element: IWebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will loop until an element is
|
||||
@@ -1348,8 +1367,8 @@ declare module webdriver {
|
||||
* to use.
|
||||
* @return {!until.Condition.<!webdriver.WebElement>} The new condition.
|
||||
*/
|
||||
function elementLocated(locator: Locator): Condition<WebElement>;
|
||||
function elementLocated(locator: any): Condition<WebElement>;
|
||||
function elementLocated(locator: Locator): Condition<IWebElement>;
|
||||
function elementLocated(locator: any): Condition<IWebElement>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element's
|
||||
@@ -1361,7 +1380,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#getText
|
||||
*/
|
||||
function elementTextContains(element: WebElement, substr: string): Condition<boolean>;
|
||||
function elementTextContains(element: IWebElement, substr: string): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element's
|
||||
@@ -1373,7 +1392,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#getText
|
||||
*/
|
||||
function elementTextIs(element: WebElement, text: string): Condition<boolean>;
|
||||
function elementTextIs(element: IWebElement, text: string): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element's
|
||||
@@ -1385,7 +1404,7 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
* @see webdriver.WebDriver#getText
|
||||
*/
|
||||
function elementTextMatches(element: WebElement, regex: RegExp): Condition<boolean>;
|
||||
function elementTextMatches(element: IWebElement, regex: RegExp): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will loop until at least one element is
|
||||
@@ -1396,8 +1415,8 @@ declare module webdriver {
|
||||
* @return {!until.Condition.<!Array.<!webdriver.WebElement>>} The new
|
||||
* condition.
|
||||
*/
|
||||
function elementsLocated(locator: Locator): Condition<WebElement[]>;
|
||||
function elementsLocated(locator: any): Condition<WebElement[]>;
|
||||
function elementsLocated(locator: Locator): Condition<IWebElement[]>;
|
||||
function elementsLocated(locator: any): Condition<IWebElement[]>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the given element to become stale. An
|
||||
@@ -1407,7 +1426,7 @@ declare module webdriver {
|
||||
* @param {!webdriver.WebElement} element The element that should become stale.
|
||||
* @return {!until.Condition.<boolean>} The new condition.
|
||||
*/
|
||||
function stalenessOf(element: WebElement): Condition<boolean>;
|
||||
function stalenessOf(element: IWebElement): Condition<boolean>;
|
||||
|
||||
/**
|
||||
* Creates a condition that will wait for the current page's title to contain
|
||||
@@ -1597,7 +1616,7 @@ declare module webdriver {
|
||||
* Defaults to (0, 0).
|
||||
* @return {!webdriver.ActionSequence} A self reference.
|
||||
*/
|
||||
mouseMove(location: WebElement, opt_offset?: ILocation): ActionSequence;
|
||||
mouseMove(location: IWebElement, opt_offset?: ILocation): ActionSequence;
|
||||
mouseMove(location: ILocation): ActionSequence;
|
||||
|
||||
/**
|
||||
@@ -1622,7 +1641,7 @@ declare module webdriver {
|
||||
* first argument.
|
||||
* @return {!webdriver.ActionSequence} A self reference.
|
||||
*/
|
||||
mouseDown(opt_elementOrButton?: WebElement, opt_button?: number): ActionSequence;
|
||||
mouseDown(opt_elementOrButton?: IWebElement, opt_button?: number): ActionSequence;
|
||||
mouseDown(opt_elementOrButton?: number): ActionSequence;
|
||||
|
||||
/**
|
||||
@@ -1645,7 +1664,7 @@ declare module webdriver {
|
||||
* first argument.
|
||||
* @return {!webdriver.ActionSequence} A self reference.
|
||||
*/
|
||||
mouseUp(opt_elementOrButton?: WebElement, opt_button?: number): ActionSequence;
|
||||
mouseUp(opt_elementOrButton?: IWebElement, opt_button?: number): ActionSequence;
|
||||
mouseUp(opt_elementOrButton?: number): ActionSequence;
|
||||
|
||||
/**
|
||||
@@ -1657,8 +1676,8 @@ declare module webdriver {
|
||||
* location to drag to, either as another WebElement or an offset in pixels.
|
||||
* @return {!webdriver.ActionSequence} A self reference.
|
||||
*/
|
||||
dragAndDrop(element: WebElement, location: WebElement): ActionSequence;
|
||||
dragAndDrop(element: WebElement, location: ILocation): ActionSequence;
|
||||
dragAndDrop(element: IWebElement, location: IWebElement): ActionSequence;
|
||||
dragAndDrop(element: IWebElement, location: ILocation): ActionSequence;
|
||||
|
||||
/**
|
||||
* Clicks a mouse button.
|
||||
@@ -1676,7 +1695,7 @@ declare module webdriver {
|
||||
* first argument.
|
||||
* @return {!webdriver.ActionSequence} A self reference.
|
||||
*/
|
||||
click(opt_elementOrButton?: WebElement, opt_button?: number): ActionSequence;
|
||||
click(opt_elementOrButton?: IWebElement, opt_button?: number): ActionSequence;
|
||||
click(opt_elementOrButton?: number): ActionSequence;
|
||||
|
||||
/**
|
||||
@@ -1698,7 +1717,7 @@ declare module webdriver {
|
||||
* first argument.
|
||||
* @return {!webdriver.ActionSequence} A self reference.
|
||||
*/
|
||||
doubleClick(opt_elementOrButton?: WebElement, opt_button?: number): ActionSequence;
|
||||
doubleClick(opt_elementOrButton?: IWebElement, opt_button?: number): ActionSequence;
|
||||
doubleClick(opt_elementOrButton?: number): ActionSequence;
|
||||
|
||||
/**
|
||||
@@ -3417,7 +3436,270 @@ declare module webdriver {
|
||||
* });
|
||||
* </code></pre>
|
||||
*/
|
||||
class WebElement {
|
||||
|
||||
interface IWebElement {
|
||||
//region Methods
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
|
||||
/**
|
||||
* 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<ISize>;
|
||||
|
||||
/**
|
||||
* 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<ILocation>;
|
||||
|
||||
/**
|
||||
* 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<boolean>;
|
||||
|
||||
/**
|
||||
* 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<boolean>;
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
|
||||
/**
|
||||
* 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<boolean>;
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
|
||||
/**
|
||||
* @return {!webdriver.promise.Promise.<webdriver.WebElement.Id>} A promise
|
||||
* that resolves to this element's JSON representation as defined by the
|
||||
* WebDriver wire protocol.
|
||||
* @see http://code.google.com/p/selenium/wiki/JsonWireProtocol
|
||||
*/
|
||||
getId(): webdriver.promise.Promise<IWebElementId>
|
||||
|
||||
/**
|
||||
* 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<string>;
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
interface IWebElementFinders {
|
||||
/**
|
||||
* 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 an element may be defined using one of the
|
||||
* factories in the {@link webdriver.By} namespace, or as a short-hand
|
||||
* {@link webdriver.By.Hash} object. 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>You may also provide a custom locator function, which takes as input
|
||||
* this WebDriver instance and returns a {@link webdriver.WebElement}, or a
|
||||
* promise that will resolve to a WebElement. For example, to find the first
|
||||
* visible link on a page, you could write:
|
||||
* <code><pre>
|
||||
* var link = element.findElement(firstVisibleLink);
|
||||
*
|
||||
* function firstVisibleLink(element) {
|
||||
* var links = element.findElements(By.tagName('a'));
|
||||
* return webdriver.promise.filter(links, function(link) {
|
||||
* return links.isDisplayed();
|
||||
* }).then(function(visibleLinks) {
|
||||
* return visibleLinks[0];
|
||||
* });
|
||||
* }
|
||||
* </pre></code>
|
||||
*
|
||||
* @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The
|
||||
* locator strategy to use when searching for the element.
|
||||
* @return {!webdriver.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: Locator): WebElementPromise;
|
||||
findElement(locator: any): WebElementPromise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if there is at least one descendant of this
|
||||
* element that matches the given search criteria.
|
||||
*
|
||||
* @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The
|
||||
* locator strategy to use when searching for the element.
|
||||
* @return {!webdriver.promise.Promise.<boolean>} A promise that will be
|
||||
* resolved with whether an element could be located on the page.
|
||||
*/
|
||||
isElementPresent(locator: Locator): webdriver.promise.Promise<boolean>;
|
||||
isElementPresent(locator: any): webdriver.promise.Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Schedules a command to find all of the descendants of this element that
|
||||
* match the given search criteria.
|
||||
*
|
||||
* @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The
|
||||
* locator strategy to use when searching for the elements.
|
||||
* @return {!webdriver.promise.Promise.<!Array.<!webdriver.WebElement>>} A
|
||||
* promise that will resolve to an array of WebElements.
|
||||
*/
|
||||
findElements(locator: Locator): webdriver.promise.Promise<WebElement[]>;
|
||||
findElements(locator: any): webdriver.promise.Promise<WebElement[]>;
|
||||
}
|
||||
|
||||
class WebElement implements IWebElement, IWebElementFinders {
|
||||
//region Constructors
|
||||
|
||||
/**
|
||||
@@ -3847,7 +4129,7 @@ declare module webdriver {
|
||||
className(value: string): Locator;
|
||||
css(value: string): Locator;
|
||||
id(value: string): Locator;
|
||||
js(script: any, ...var_args): (WebDriver) => webdriver.promise.Promise<any>;
|
||||
js(script: any, ...var_args: any[]): (WebDriver: webdriver.WebDriver) => webdriver.promise.Promise<any>;
|
||||
linkText(value: string): Locator;
|
||||
name(value: string): Locator;
|
||||
partialLinkText(value: string): Locator;
|
||||
|
||||
Reference in New Issue
Block a user