admin管理员组文章数量:1291125
I'm trying to get the disabled attr on a button it should be "disabled" but I don't seem to be getting the value. New to angular and protractor!
When I inspect the page this is what HTML I get for the button showing disabled is disabled, like it is on the page:
<button type="submit" class="button primary inverse" ng-disabled="!ment.$dirty && ment.$valid" disabled="disabled">Save</button>
The protractor test below returns 'Expected null to equal disabled'
var btnSave = element(by.css('.primary'));
expect(btnSave.isPresent()).toBeTruthy();
var attr = element(by.css('.primary')).getAttribute('disabled');
expect(attr).toEqual("disabled");
When I try I get expected '' to equal disabled.
expect(attr).toEqual("disabled");
Any ideas where I'm going wrong?
Thanks
I'm trying to get the disabled attr on a button it should be "disabled" but I don't seem to be getting the value. New to angular and protractor!
When I inspect the page this is what HTML I get for the button showing disabled is disabled, like it is on the page:
<button type="submit" class="button primary inverse" ng-disabled="!ment.$dirty && ment.$valid" disabled="disabled">Save</button>
The protractor test below returns 'Expected null to equal disabled'
var btnSave = element(by.css('.primary'));
expect(btnSave.isPresent()).toBeTruthy();
var attr = element(by.css('.primary')).getAttribute('disabled');
expect(attr).toEqual("disabled");
When I try I get expected '' to equal disabled.
expect(attr).toEqual("disabled");
Any ideas where I'm going wrong?
Thanks
Share Improve this question edited Jan 30, 2016 at 9:52 giri-sh 6,9622 gold badges27 silver badges50 bronze badges asked Jan 29, 2016 at 12:50 thegunnerthegunner 7,16334 gold badges97 silver badges144 bronze badges 1-
I wonder if
isEnabled()
(or the Promisifiednot
version of that) work to determine disabled? – Nate Anderson Commented Jul 30, 2017 at 21:57
1 Answer
Reset to default 7getAttribute()
function in protractor returns value in the form of promise. So either you have wait until its returned and then perform validation or you can pass in the function to the expectation
which in turn resolves the promise. disabled
html attribute is a boolean attribute and hence the value that it returns is either true
or false
. Here's how -
element(by.css('.primary')).getAttribute('disabled').then(function(attr){
expect(attr).toBe(true);
});
OR
expect(element(by.css('.primary')).getAttribute('disabled')).toBe(true);
Hope it helps.
本文标签: javascriptusing protractor to get the disabled attribute on button not workingStack Overflow
版权声明:本文标题:javascript - using protractor to get the disabled attribute on button not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741509460a2382521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论