本文整理匯總了TypeScript中protractor.ElementArrayFinder.map方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ElementArrayFinder.map方法的具體用法?TypeScript ElementArrayFinder.map怎麽用?TypeScript ElementArrayFinder.map使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類protractor.ElementArrayFinder
的用法示例。
在下文中一共展示了ElementArrayFinder.map方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getClassStates
/**
* Returns an array of true/false values that represents whether the provided className is on
* each element.
*/
function getClassStates(elements: ElementArrayFinder, className: string) {
return elements.map(element => {
return element.getAttribute('class').then(classes => {
return classes.split(/ +/g).indexOf(className) >= 0;
});
});
}
示例2: getFocusStates
/**
* Returns an array of true/false that represents the focus states of the provided elements.
*/
async function getFocusStates(elements: ElementArrayFinder) {
return elements.map(async el => {
const elementText = await el!.getText();
const activeText = await browser.driver.switchTo().activeElement().getText();
return activeText === elementText;
});
}
示例3: getFocusStates
/**
* Returns an array of true/false that represents the focus states of the provided elements.
*/
function getFocusStates(elements: ElementArrayFinder) {
return elements.map(element => {
return element.getText().then(elementText => {
return browser.driver.switchTo().activeElement().getText().then(activeText => {
return activeText === elementText;
});
});
});
}
示例4: getClassStates
/**
* Returns an array of true/false values that represents whether the provided className is on
* each element.
*/
async function getClassStates(elements: ElementArrayFinder, className: string) {
return elements.map(async el => {
const classes = await el!.getAttribute('class');
return classes.split(/ +/g).indexOf(className) > -1;
});
}