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="!comment.$dirty && comment.$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
getAttribute()
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 theexpectation
which in turn resolves the promise.disabled
html attribute is a boolean attribute and hence the value that it returns is eithertrue
orfalse
. Here's how -OR
Hope it helps.