Yokesh Varadhan
Yokesh Varadhan

Reputation: 1636

counting no of array element an array

ineed to get the number of elements created at every instance when a button is click

<a class="item-content ng-binding" ng-href="#/lead/details/0/quotation/view/0/" target="_self" href="#/lead/details/0/quotation/view/0/">
            2015-10-22 - 1000674
        </a>

every time i click on a button a new element is been created with a serial number i need to find out the count of elements after every button clicks i used

var quotationNumber         = element.all(by.css('.item-content.ng-binding'));

it('should display Correct Quotation number in Lead Page',function(){
        expect(quotationNumber.getText()).count();
    });

my terminal sends an error message TypeError: expect(...).count is not a function. i need the size of that array elements. could some one help me to fix this issue

Upvotes: 0

Views: 107

Answers (2)

maurycy
maurycy

Reputation: 8465

When you use element.all the returned promise has method count the getText called on element.all(selector).getText() returns an array of text so for that you can use length

var quotationNumber = element.all(by.css('.item-content.ng-binding'));

it('should display Correct Quotation number in Lead Page',function(){
        expect(quotationNumber.count()).toBe(3);
    });

Upvotes: 1

jkris
jkris

Reputation: 6511

Have you tried changing expect(quotationNumber.getText()).count(); to expect(quotationNumber.getText().count()); ?

Upvotes: 0

Related Questions