Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 testing - Get element by Id

Tags:

angular

I'm writing an Angular2 test component and i've noticed this line in the tutorials:

de = fixture.debugElement.query(By.css('h1')); 

de is defined as DebugElement type.

How can I get DebugElement by id?

That may seem extremely simple but I can't find any direction in the docs.

like image 740
ohadinho Avatar asked Dec 30 '16 16:12

ohadinho


1 Answers

You can also use by.css

de = fixture.debugElement.query(By.css('#theid')); 
like image 128
J J B Avatar answered Oct 05 '22 23:10

J J B