本文整理汇总了TypeScript中protractor.promise类的典型用法代码示例。如果您正苦于以下问题:TypeScript promise类的具体用法?TypeScript promise怎么用?TypeScript promise使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了promise类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: retrieveRegistryItem
// Get the current list of ids and data from opened registry section
static retrieveRegistryItem() {
let idsPromise = OperationsHelper.retrieveMatchingElementsByCSS('.resource-list', '.resource-container .id', 0)
.map((elm) => {
browser.executeScript(scrollMe, elm);
return OperationsHelper.retrieveTextFromElement(elm);
});
let dataPromise = OperationsHelper.retrieveMatchingElementsByCSS('.resource-list', '.resource-container .data', 0)
.map((elm) => {
browser.executeScript(scrollMe, elm);
return OperationsHelper.retrieveTextFromElement(elm);
});
let promises = [idsPromise, dataPromise];
return promise.all(promises)
.then((values) => {
let ids = values[0];
let data = values[1];
let result = ids.map((val, index) => {
return { id: val, data: data[index] };
});
return result;
});
}
示例2: return
return sortIcon.isPresent().then(present => {
if (!present) {
// Wrapping this in a promise for consistent return types.
// necessary to avoid typescript warnings in the simplest possible way.
return promise.fulfilled(SORT_TYPE.UNSORTED);
}
return sortIcon.getAttribute('class').then(className => {
return (className.indexOf('ascending') > -1 ? SORT_TYPE.ASCENDING : SORT_TYPE.DESCENDING);
});
});
示例3: it
it('should create and save Labels', async () => {
const nbButtonsBeforeCreate = await labelComponentsPage.countDeleteButtons();
await labelComponentsPage.clickOnCreateButton();
await promise.all([labelUpdatePage.setLabelInput('label')]);
expect(await labelUpdatePage.getLabelInput()).to.eq('label', 'Expected Label value to be equals to label');
await labelUpdatePage.save();
expect(await labelUpdatePage.getSaveButton().isPresent(), 'Expected save button disappear').to.be.false;
expect(await labelComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeCreate + 1, 'Expected one more entry in the table');
});
示例4: it
it('should create and save Labels', async () => {
const nbButtonsBeforeCreate = await labelComponentsPage.countDeleteButtons();
await labelComponentsPage.clickOnCreateButton();
await promise.all([labelUpdatePage.setLabelInput('label')]);
expect(await labelUpdatePage.getLabelInput()).to.eq('label');
await labelUpdatePage.save();
expect(await labelUpdatePage.getSaveButton().isPresent()).to.be.false;
expect(await labelComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeCreate + 1);
});
示例5:
let transformDataAndLink = (definition: ElementFinder) => {
let promises = [definition.getText(), definition.$('a').getAttribute('href')];
return promise.all(promises).then(results => {
// 'Some data (Link)' -> ['Some data', 'link']
let text = results[0].split('(')[0].trim();
let linkText = results[0].split('(')[1].replace(')', '');
return {
text,
href: results[1],
linkText,
};
});
};
示例6: it
it('should create and save BankAccounts', async () => {
const nbButtonsBeforeCreate = await bankAccountComponentsPage.countDeleteButtons();
await bankAccountComponentsPage.clickOnCreateButton();
await promise.all([
bankAccountUpdatePage.setNameInput('name'),
bankAccountUpdatePage.setBalanceInput('5'),
bankAccountUpdatePage.userSelectLastOption()
]);
expect(await bankAccountUpdatePage.getNameInput()).to.eq('name');
expect(await bankAccountUpdatePage.getBalanceInput()).to.eq('5');
await bankAccountUpdatePage.save();
expect(await bankAccountUpdatePage.getSaveButton().isPresent()).to.be.false;
expect(await bankAccountComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeCreate + 1);
});
示例7: it
it('should create and save BankAccounts', async () => {
const nbButtonsBeforeCreate = await bankAccountComponentsPage.countDeleteButtons();
await bankAccountComponentsPage.clickOnCreateButton();
await promise.all([
bankAccountUpdatePage.setNameInput('name'),
bankAccountUpdatePage.setBalanceInput('5'),
bankAccountUpdatePage.userSelectLastOption()
]);
expect(await bankAccountUpdatePage.getNameInput()).to.eq('name', 'Expected Name value to be equals to name');
expect(await bankAccountUpdatePage.getBalanceInput()).to.eq('5', 'Expected balance value to be equals to 5');
await bankAccountUpdatePage.save();
expect(await bankAccountUpdatePage.getSaveButton().isPresent(), 'Expected save button disappear').to.be.false;
expect(await bankAccountComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeCreate + 1, 'Expected one more entry in the table');
});
示例8: it
it('should create and save Operations', async () => {
const nbButtonsBeforeCreate = await operationComponentsPage.countDeleteButtons();
await operationComponentsPage.clickOnCreateButton();
await promise.all([
operationUpdatePage.setDateInput('01/01/2001' + protractor.Key.TAB + '02:30AM'),
operationUpdatePage.setDescriptionInput('description'),
operationUpdatePage.setAmountInput('5'),
operationUpdatePage.bankAccountSelectLastOption()
// operationUpdatePage.labelSelectLastOption(),
]);
expect(await operationUpdatePage.getDateInput()).to.contain('2001-01-01T02:30');
expect(await operationUpdatePage.getDescriptionInput()).to.eq('description');
expect(await operationUpdatePage.getAmountInput()).to.eq('5');
await operationUpdatePage.save();
expect(await operationUpdatePage.getSaveButton().isPresent()).to.be.false;
expect(await operationComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeCreate + 1);
});
示例9: it
it('should create and save Operations', async () => {
const nbButtonsBeforeCreate = await operationComponentsPage.countDeleteButtons();
await operationComponentsPage.clickOnCreateButton();
await promise.all([
operationUpdatePage.setDateInput('01/01/2001' + protractor.Key.TAB + '02:30AM'),
operationUpdatePage.setDescriptionInput('description'),
operationUpdatePage.setAmountInput('5'),
operationUpdatePage.bankAccountSelectLastOption()
// operationUpdatePage.labelSelectLastOption(),
]);
expect(await operationUpdatePage.getDateInput()).to.contain('2001-01-01T02:30', 'Expected date value to be equals to 2000-12-31');
expect(await operationUpdatePage.getDescriptionInput()).to.eq('description', 'Expected Description value to be equals to description');
expect(await operationUpdatePage.getAmountInput()).to.eq('5', 'Expected amount value to be equals to 5');
await operationUpdatePage.save();
expect(await operationUpdatePage.getSaveButton().isPresent(), 'Expected save button disappear').to.be.false;
expect(await operationComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeCreate + 1, 'Expected one more entry in the table');
});
示例10: Error
.then((items) => {
let promises = [];
for (let i = 0; i < items.length; i++) {
let id = items[0].element(by.css('.id'));
promises.push(OperationsHelper.retrieveTextFromElement(id));
}
return promise.all(promises).then((texts) => {
let id = -1;
texts.forEach((text, index) => {
if (text === identifier) {
id = index;
}
});
if (id === -1) {
throw new Error('Particpant not found: ' + identifier);
}
return items[id];
});
})