get two divs by class name in karma test (Angular 4.0)
问题 I have something like this in view: <div> <div class="header-title">Example title 1</div> </div> <div> <div class="header-title">Example title 2</div> </div> In my karma test I would like to investigate all divs by class name and check if inner text is correct so I have following code in test: [...] debugTest = fixture.debugElement.query(By.css('.header-title')); elementTest = debugTest.nativeElement; [...] it('should component div has a correct value', () => { fixture.detectChanges(); const