Reputation: 3904
I have a component containing 3 select dropdowns with no css classes attached and a unique Id on each. In my component I want to get the elements as DebugElements so that I can test their states after various events have been triggered. From the Angular website there is debugElement.query(By.css('[attribute]'));
. How can I get my dropdowns By.id
Upvotes: 5
Views: 14868
Reputation: 6963
Angular 7 get debugElement by ID
The debugElement.query iterates all debugElements and returns those found to be true via a predicate. This example shows how to do it in one line of code.
var test = fixture.debugElement.query((de)=>{return de.nativeElement.id==="someId"});
Upvotes: 2