當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript promise.all方法代碼示例

本文整理匯總了TypeScript中selenium-webdriver.promise.all方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript promise.all方法的具體用法?TypeScript promise.all怎麽用?TypeScript promise.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在selenium-webdriver.promise的用法示例。


在下文中一共展示了promise.all方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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;
 }
開發者ID:NickTomlin,項目名稱:protractor,代碼行數:16,代碼來源:driverProvider.ts

示例2: _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));
    }
開發者ID:vmanikandan001,項目名稱:xcngr,代碼行數:13,代碼來源:m2indiaProvider.ts

示例3: _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}`));
    }
開發者ID:vmanikandan001,項目名稱:xcngr,代碼行數:14,代碼來源:m2indiaProvider.ts

示例4: 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;
 }
開發者ID:DylanLacey,項目名稱:protractor,代碼行數:20,代碼來源:driverProvider.ts

示例5:

 .then(resultPromise => promise.all(resultPromise));
開發者ID:vmanikandan001,項目名稱:xcngr,代碼行數:1,代碼來源:m2indiaProvider.ts

示例6: TestPromiseModule

function TestPromiseModule() {
    let cancellationError: webdriver.promise.CancellationError = new webdriver.promise.CancellationError();
    cancellationError = new webdriver.promise.CancellationError('message');
    let str: string = cancellationError.message;
    str = cancellationError.name;

    let numberPromise: webdriver.promise.Promise<number>;
    let booleanPromise: webdriver.promise.Promise<boolean>;
    let voidPromise: webdriver.promise.Promise<void>;

    webdriver.promise.all([stringPromise]).then((values: string[]) => {});

    webdriver.promise.asap('abc', (value: any) => true);
    webdriver.promise.asap('abc', (value: any) => {}, (err: any) => 'ABC');

    stringPromise = webdriver.promise.checkedNodeCall<string>((err: any, value: any) => 'abc');

    webdriver.promise.consume(() => {
        return 5;
    }).then((value: number) => {});
    webdriver.promise.consume(() => {
        return 5;
    }, this).then((value: number) => {});
    webdriver.promise.consume((a: number, b: number, c: number) => 5, this, 1, 2, 3)
        .then((value: number) => {});

    let numbersPromise: webdriver.promise.Promise<number[]> = webdriver.promise.filter([1, 2, 3], (element: number, type: any, index: number, arr: number[]) => {
        return true;
    });
    numbersPromise = webdriver.promise.filter([1, 2, 3], (element: number, type: any, index: number, arr: number[]) => {
        return true;
    }, this);
    numbersPromise = webdriver.promise.filter(numbersPromise, (element: number, type: any, index: number, arr: number[]) => {
        return true;
    });
    numbersPromise = webdriver.promise.filter(numbersPromise, (element: number, type: any, index: number, arr: number[]) => {
        return true;
    }, this);

    numbersPromise = webdriver.promise.map([1, 2, 3], (el: number, type: any, index: number, arr: number[]) => {
        return true;
    });
    numbersPromise = webdriver.promise.map([1, 2, 3], (el: number, type: any, index: number, arr: number[]) => {
        return true;
    }, this);
    numbersPromise = webdriver.promise.map(numbersPromise, (el: number, type: any, index: number, arr: number[]) => {
        return true;
    });
    numbersPromise = webdriver.promise.map(numbersPromise, (el: number, type: any, index: number, arr: number[]) => {
        return true;
    }, this);

    let flow: webdriver.promise.ControlFlow = webdriver.promise.controlFlow();

    stringPromise = webdriver.promise.createFlow<string>((newFlow: webdriver.promise.ControlFlow) => 'ABC');

    let deferred: webdriver.promise.Deferred<string>;
    deferred = webdriver.promise.defer<string>();
    deferred = webdriver.promise.defer<string>();

    stringPromise = deferred.promise;

    deferred.fulfill('ABC');
    deferred.reject('error');

    voidPromise = webdriver.promise.delayed(123);

    voidPromise = webdriver.promise.fulfilled<void>();
    stringPromise = webdriver.promise.fulfilled('abc');

    stringPromise = webdriver.promise.fullyResolved<string>('abc');

    let bool: boolean = webdriver.promise.isGenerator(() => {});
    let isPromise: boolean = webdriver.promise.isPromise('ABC');

    stringPromise = webdriver.promise.rejected<string>('{a: 123}');

    webdriver.promise.setDefaultFlow(new webdriver.promise.ControlFlow());

    numberPromise = webdriver.promise.when('abc', (value: any) => 123, (err: Error) => 123);
}
開發者ID:Rick-Kirkham,項目名稱:DefinitelyTyped,代碼行數:81,代碼來源:index.ts

示例7: TestPromiseModule

function TestPromiseModule() {
    var cancellationError: webdriver.promise.CancellationError = new webdriver.promise.CancellationError();
    cancellationError = new webdriver.promise.CancellationError('message');
    var str: string = cancellationError.message;
    str = cancellationError.name;

    var stringPromise: webdriver.promise.Promise<string>;
    var numberPromise: webdriver.promise.Promise<number>;
    var booleanPromise: webdriver.promise.Promise<boolean>;
    var voidPromise: webdriver.promise.Promise<void>;

    webdriver.promise.all([stringPromise]).then(function (values: string[]) { });

    webdriver.promise.asap('abc', function (value: any) { return true; });
    webdriver.promise.asap('abc', function (value: any) { }, function (err: any) { return 'ABC'; });

    stringPromise = webdriver.promise.checkedNodeCall<string>(function (err: any, value: any) { return 'abc'; });

    webdriver.promise.consume(function () {
        return 5;
    }).then(function (value: number) { });
    webdriver.promise.consume(function () {
        return 5;
    }, this).then(function (value: number) { });
    webdriver.promise.consume(function (a: number, b: number, c: number) {
        return 5;
    }, this, 1, 2, 3).then(function (value: number) { });

    var numbersPromise: webdriver.promise.Promise<number[]> = webdriver.promise.filter([1, 2, 3], function (element: number, type: any, index: number, arr: number[]) {
        return true;
    });
    numbersPromise = webdriver.promise.filter([1, 2, 3], function (element: number, type: any, index: number, arr: number[]) {
        return true;
    }, this);
    numbersPromise = webdriver.promise.filter(numbersPromise, function (element: number, type: any, index: number, arr: number[]) {
        return true;
    });
    numbersPromise = webdriver.promise.filter(numbersPromise, function (element: number, type: any, index: number, arr: number[]) {
        return true;
    }, this);

    numbersPromise = webdriver.promise.map([1, 2, 3], function (el: number, type: any, index: number, arr: number[]) {
        return true;
    });
    numbersPromise = webdriver.promise.map([1, 2, 3], function (el: number, type: any, index: number, arr: number[]) {
        return true;
    }, this);
    numbersPromise = webdriver.promise.map(numbersPromise, function (el: number, type: any, index: number, arr: number[]) {
        return true;
    });
    numbersPromise = webdriver.promise.map(numbersPromise, function (el: number, type: any, index: number, arr: number[]) {
        return true;
    }, this);

    var flow: webdriver.promise.ControlFlow = webdriver.promise.controlFlow();

    stringPromise = webdriver.promise.createFlow<string>(function (newFlow: webdriver.promise.ControlFlow) { return 'ABC' });

    var deferred: webdriver.promise.Deferred<string>;
    deferred = webdriver.promise.defer();
    deferred = webdriver.promise.defer();

    stringPromise = deferred.promise;

    deferred.fulfill('ABC');
    deferred.reject('error');

    voidPromise = webdriver.promise.delayed(123);

    voidPromise = webdriver.promise.fulfilled<void>();
    stringPromise = webdriver.promise.fulfilled('abc');

    stringPromise = webdriver.promise.fullyResolved('abc');

    var bool: boolean = webdriver.promise.isGenerator(function () { });
    var isPromise: boolean = webdriver.promise.isPromise('ABC');

    stringPromise = webdriver.promise.rejected('{a: 123}');

    webdriver.promise.setDefaultFlow(new webdriver.promise.ControlFlow());

    numberPromise = webdriver.promise.when('abc', function (value: any) { return 123; }, function (err: Error) { return 123; });
}
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:83,代碼來源:index.ts


注:本文中的selenium-webdriver.promise.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。