angularjs - Protractor tests in Angular: how to check variable in scope without ng-bind and ng-model? -
how check variable in scope without ng-bind , ng-model ?
<span ng-if="user.code === 'yellow'"> <span class="glyphicons glyphicons-circle-remove text-danger"></span> yellow </span> <span ng-if="user.code === 'green'"> <span class="glyphicons glyphicons-circle-exclamation-mark text-warning"></span> green </span>
i check user.code protractor
with ng-bind , ng-model doesn't work
browser.expect(element(by.binding('user.code')).gettext()).to.eventually.equal('');
or
browser.expect(element(by.model('user.code')).getattribute('value')).to.eventually.equal('');
error :
nosuchelementerror: no element found using locator: by.binding("user.code") nosuchelementerror: no element found using locator: by.model("user.code")
you should not testing kind of stuff in protractor. should write tests perspective of user.
however, if want test use evaluate
. reference dom element , call evaluate:
// choose dom element bound scope contains value // want test expect($('span').evaluate('user.code')).tobe('some value');
http://www.protractortest.org/#/api?view=elementarrayfinder.prototype.evaluate
Comments
Post a Comment