本文整理匯總了TypeScript中protractor.ElementFinder.getAttribute方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ElementFinder.getAttribute方法的具體用法?TypeScript ElementFinder.getAttribute怎麽用?TypeScript ElementFinder.getAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類protractor.ElementFinder
的用法示例。
在下文中一共展示了ElementFinder.getAttribute方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getBodyScrollHeight
getBodyScrollHeight(): promise.Promise<number> {
const body: ElementFinder = element(by.css('body'));
return body.getAttribute('scrollHeight').then((bodyScrollHeightString: string) => {
return +bodyScrollHeightString;
});
}
示例2: it
it('should select value and close dropdown', async () => {
select.element(by.css('.ng-select-container')).click();
select.all(by.css('.ng-option')).first().click();
expect(select.getAttribute('class')).not.toMatch('ng-select-opened');
const text = await element(by.id('ngModel')).getText();
expect(text).toEqual('1');
});
示例3: check
export function check(el: ElementFinder) {
Util.waitUntilElementIsVisible(el);
el.getAttribute('class').then((classList) => {
if (classList && classList.indexOf('mat-checked') === -1) {
el.click();
expect(el.getAttribute('class')).toContain('mat-checked');
}
});
}
示例4: changeInputValue
public static changeInputValue(elemFinder: ElementFinder, fieldName: string, viewModel: any, backupModel?: any) {
elemFinder.getAttribute('value').then((value: string) => {
if (backupModel) {
backupModel[fieldName] = value;
}
elemFinder.clear();
elemFinder.sendKeys(viewModel[fieldName]);
console.log('Change value for ' + fieldName + ' from "' + value + '" to "' + viewModel[fieldName] + '"');
});
}
示例5: appendTimestamp
public static appendTimestamp(elemFinder: ElementFinder, timestamp: string) {
elemFinder.getAttribute('value').then((value: string) => {
let index: number = value.indexOf('@');
if(index > 0) {
value = value.substring(0, index);
}
elemFinder.clear();
elemFinder.sendKeys(value + timestamp);
});
}
示例6: getElementAttribute
async getElementAttribute(xpath:string, attribute:string):Promise<string>{
var ele:ElementFinder = await this.curBrowser.element(by.xpath(xpath))
var attributeValue:string =""
await this.curBrowser.wait(this.until.presenceOf(ele), this.timeOut, 'Element ' + xpath + ' takes too long to appear in the DOM' )
await ele.getAttribute(attribute).then(function(value){
console.log("Attribute value: " + value)
attributeValue = value
})
return attributeValue
}
示例7: checkInputValueEqual
public static checkInputValueEqual(elemFinder: ElementFinder, elemName: string, expectValue: string | number) {
elemFinder.getAttribute('value').then((value: string) => {
if(typeof expectValue === 'number') {
expect(value).toEqual(expectValue.toString());
console.log('Check if ' + elemName + ' is "' + value + '": ' + (expectValue.toString() === value));
} else {
expect(value).toEqual(expectValue);
console.log('Check if ' + elemName + ' is "' + value + '": ' + (expectValue === value));
}
});
}
示例8: return
return (target, propertyKey): PropertyDescriptor => {
return {
get() {
return elem.getAttribute('value');
},
set(input) {
elem.clear();
elem.sendKeys(input);
},
};
};
示例9: it
it('should populate the form control values in the DOM', () => {
expect(firstInput.getAttribute('value')).toEqual('Nancy');
expect(lastInput.getAttribute('value')).toEqual('Drew');
});
示例10: it
it('should set the value by changing the domain model', () => {
button.click();
expect(input.getAttribute('value')).toEqual('Nancy');
});