Reputation: 3904
In an Angular component test, how can the sect value of a Select/dropdown be retrieved in a test?
I can get the value using expect(selectElement.nativeElement.value).toBe('1');
but cant figure out how to get the Text value to test
Upvotes: 2
Views: 2587
Reputation: 573
You can get the .innerText
from the selected option:
var select = selectElement.nativeElement;
var text = select.options[select.selectedIndex].innerText
Upvotes: 2