Skip to content Skip to sidebar Skip to footer

Test For The Number Of Elements Using Jasmine In Angularjs

I am writing an end to end test using Jasmine for AngularJS. I am using Protractor to run the test. I have the following markup
  • Solution 1:

    This question is part of the Experiments section in tutorial 8 of the AngularJS tutorial.

    Here is how I solved it. I took the different road of counting the images rendered rather than testing the repeater/model directly.

    it('should display four thumbnails of the nexus-s', function() {
      var imgsCount = element.all(by.css('.phone-thumbs li img')).count();
      expect(imgsCount).toBe(4);
    });
    

    Solution 2:

    For anyone who needs to know this. Here's how I did it.

    it('should display four thumbnails on the nexus-s page', function() {
          var images = element.all(by.repeater('img in phone.images')).count();
          expect(images).toBe(4);
        });
    

Post a Comment for "Test For The Number Of Elements Using Jasmine In Angularjs"