本文整理汇总了TypeScript中selenium-webdriver.promise类的典型用法代码示例。如果您正苦于以下问题:TypeScript promise类的具体用法?TypeScript promise怎么用?TypeScript promise使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了promise类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should call execute on fulfilled executors', (done) => {
let deferred = webdriver.promise.defer();
var deferredExecutor = new DeferredExecutor(deferred.promise);
deferred.fulfill(makeExecutor(done));
deferredExecutor.execute('command');
});
示例2: buildPath
this.schedule = (command: Command, description: string) => {
command.setParameter('sessionId', sessionId);
var params = command.getParameters();
return webdriver.promise.fulfilled(execCallback(
buildPath(this.paths_[command.getName()], params),
description, params));
};
示例3: buildPath
execute: (command: webdriver.Command) => {
command.setParameter('sessionId', sessionId);
let params = command.getParameters();
return webdriver.promise.fulfilled(execCallback(
buildPath(paths[command.getName()], params),
methods[command.getName()], params));
},
示例4: navigateToCurrentUrlWithNewBrowser
navigateToCurrentUrlWithNewBrowser(): webDriverPromise.Promise<EsfHome> {
var esfHome2 = new EsfHome(browser.forkNewDriverInstance());
var deferredResult = webDriverPromise.defer<EsfHome>();
this.getCurrentUrl().then((url) => {
esfHome2.navigateToUrl(url);
deferredResult.fulfill(esfHome2);
});
return deferredResult.promise;
}
示例5: quitDrivers
/**
* Quits an array of drivers and returns a native promise instead of a webdriver one
*
* @param drivers {webdriver.WebDriver[]} The webdriver instances
*/
static quitDrivers(provider: DriverProvider, drivers: WebDriver[]): Promise<void> {
let deferredResolve: (x?: any) => void;
let deferredReject: (x?: any) => void;
let deferred = new Promise<void>((resolve, reject) => {
deferredResolve = resolve;
deferredReject = reject;
});
wdpromise.all(drivers.map((driver: WebDriver) => provider.quitDriver(driver)))
.then(() => deferredResolve(), () => deferredReject());
return deferred;
}
示例6: _getRatesForIndicative
private _getRatesForIndicative(skipOptionClick) {
var promises = [];
if (!skipOptionClick) {
promises.push(this._waitAndClick(By.xpath(`//*[@id='nonINRradio']/*[@id='moneyType']`)));
}
promises.push(driver.wait(until.elementLocated(By.xpath(`//*[@id="txnAmountDiv1"]/input`)), 5 * 1000)
.then(el => el.sendKeys('1000')));
promises.push(this._waitAndClick(By.xpath(`//a[@onclick='calculate();']`)));
return promise.all(promises)
.then(_ => this._extractRates(true))
.then(resultPromise => promise.all(resultPromise));
}
示例7: _setSearchParameters
private _setSearchParameters(currency, transferMode, deliveryMode) {
driver.get(URL);
var locators = [
By.xpath(`//*[@id='currencyId']/option[text()='${currency}'] `),
By.xpath(`//*[@id='product']/option[text()='${transferMode}'] `),
By.xpath(`//*[@id='deliveryMode']/option[text()='${deliveryMode}']`)];
var promises = locators.map(locator => this._waitAndClick(locator));
return promise.all(promises)
.then(_ => console.log(`Search parameters currency: ${currency}, transferMode:${transferMode}, deliveryMode: ${deliveryMode} set successfully`))
.thenCatch(err => console.log(`Error while setting search parameters currency:
${currency}, transferMode:${transferMode}, deliveryMode: ${deliveryMode}. Error: ${err.message}`));
}
示例8: quitDrivers
/**
* Quits an array of drivers and returns a q promise instead of a webdriver one
*
* @param drivers {webdriver.WebDriver[]} The webdriver instances
*/
static quitDrivers(provider: DriverProvider, drivers: WebDriver[]): q.Promise<void> {
let deferred = q.defer<void>();
wdpromise
.all(drivers.map((driver: WebDriver) => {
return provider.quitDriver(driver);
}))
.then(
() => {
deferred.resolve();
},
() => {
deferred.resolve();
});
return deferred.promise;
}
示例9: getElementArrayAsList
/**
* The given array is of promises. Resolve those and return as an array of strings of the element.getText()
* @param array
* @return
*/
public static getElementArrayAsList(array: ElementArrayFinder): promise.Promise<string[]> {
let deferred = promise.defer();
let out: string[] = new Array<string>();
array.then((elements) => {
elements.forEach((element: ElementFinder) => {
element.getText().then(
(text: string) => {
if (text.length > 0) {
out.push(text);
}
}
);
});
});
deferred.fulfill(out);
return deferred.promise;
}