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
Thanks to @jonrsharpe
By.css('#someId')
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"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With