当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript promise.fulfilled方法代码示例

本文整理汇总了TypeScript中selenium-webdriver.promise.fulfilled方法的典型用法代码示例。如果您正苦于以下问题:TypeScript promise.fulfilled方法的具体用法?TypeScript promise.fulfilled怎么用?TypeScript promise.fulfilled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium-webdriver.promise的用法示例。


在下文中一共展示了promise.fulfilled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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));
 };
开发者ID:sjelin,项目名称:webdriver-js-extender,代码行数:7,代码来源:mockdriver.ts

示例2: 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));
 },
开发者ID:angular,项目名称:webdriver-js-extender,代码行数:7,代码来源:mockdriver.ts

示例3: findByXPath

// Fake findByXPath for simple XPath expressions to allow usage with shadow dom
function findByXPath(node: WebElement, path: string): promise.Promise<WebElement> {
    // if there wasn't polymer with it's shadow dom useage one would like to use:

     let paths = convertPath(path);
     let n = promise.fulfilled(node);
     for (let p of paths) {
         // n = n.then(nd => nd.findElements(By.tagName(p.tagName))).then(elems => { // costly since it fetches all elements
         n = n.then(nd => nd.findElements(By.css(p.tagName+":nth-child("+(p.index)+")"))).then(elems => {
             if (elems==null || elems.length==0) { console.log("not found"); return null}; 
             return elems[0];
         }).catch(e => {console.log("REJECTED PROMISE",e); return null;});
     }
     return n;    
  
    // if (!useShadowRoot) {
    //     return node.findElements(By.xpath(path)).then(nodes => {
    //             if (nodes.length === 0) {
    //                 return null;
    //             } else {
    //                 return nodes[0];
    //             }
    //     })
    // } else {
    //     let paths = convertPath(path);
    //     let n = promise.fulfilled(node);
    //     for (let p of paths) {
    //         n = n.then(nd => nd.findElements(By.tagName(p.tagName))).then(elems => { // costly since it fetches all elements
    //             if (elems.length < p.index) { console.log("not found"); return null}; //throw "Element not found "+p.tagName+"["+p.index+"]";
    //             return elems[p.index-1];
    //         });
    //         // n = n.then(nd => nd.findElements(By.css(p.tagName+":nth-child("+(p.index)+")"))).then(elems => {
    //         //     console.log("*", elems.length);
    //         //     if (elems.length==0) { console.log("not found"); return null}; //throw "Element not found "+p.tagName+"["+p.index+"]";
    //         //     return elems[0];
    //         // });
    //     }
    //     return n;
    // }
}
开发者ID:leeoniya,项目名称:js-framework-benchmark,代码行数:40,代码来源:webdriverAccess.ts

示例4: 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

示例5: 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.fulfilled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。