0

Below is the html code:

<tab id="briefcase" ng-controller="BriefcaseController as vm" active="main.uiState.briefcaseOpen">
        <tab-heading>
           <i class="glyphicon glyphicon-briefcase"></i><br>
            My Court Cases <span id="briefcaseCount" ng-show="main.briefcase.contents.length" class="badge">{{main.briefcase.contents.length}}</span>
        </tab-heading>
        <ng-include src="'app/components/briefcase/briefcase.html'"></ng-include>
    </tab>

I followed the example given in protractor API: view:

<span id="foo">{{variableInScope}}</span>

code:

var value = element(by.id('foo')).evaluate('variableInScope');

in my case since I have 2 instances with same expression, I did the following:

var value = element.all(by.id('briefcaseCount')).get(0).evaluate('main.briefcase.contents.length');

When I call console.log(value).. I am getting [object, Object] Any help is appreciated.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195

1 Answers1

0

You need to resolve the promise to see the real value on the console:

element.all(by.id('briefcaseCount')).first().evaluate('main.briefcase.contents.length').then(function (value) {
    console.log(value);
});

If you just need to assert value, pass it to expect() - it would implicitly resolve the promise:

var value = element.all(by.id('briefcaseCount')).first().evaluate('main.briefcase.contents.length');
expect(value).toEqual("somevalue");
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195