如果我的角应用程序中的按钮已启用,我需要检查Protractor,因为这是我的测试:
it('submit should not be enabled',function() {
var price = by.name('price'),
oldCategory = by.name('oldCategory'),
newCategory = by.name('newCategory'),
oldPayment = by.name('oldPayment'),
newPayment = by.name('newPayment'),
item = by.name('item'),
submit = by.id('submitButton');
expect(submit.isEnabled().toBe(false));
});
当我运行测试时,出现此错误:
TypeError: Object By.name("price") has no method 'isEnabled'
答案 0 :(得分:15)
括号在expectation
:
expect(submit.isEnabled().toBe(false));
它应该是:
expect(submit.isEnabled()).toBe(false);
submit = by.id('submitButton');
它应该是:
submit = element(by.id('submitButton'));
您可以在specs of protractor中找到很多示例。
答案 1 :(得分:1)
尝试以下方法:
submit = element(by.id('submitButton'));