I am a newcomer to Angular and have written some code that includes two dropdown menus using simple HTML select
and option
tags. While these menus are functioning correctly, the QA team is having trouble testing them. How can I dynamically add a data-automation-id
for each option at runtime? The options are being generated from an array using ngFor
. Below is my code:
newcalendar.component.html
<select data-automation-id="timeselection-mode-primary">
<option *ngFor="let mode of modes">
{{ mode }}
</option>
</select>
...
<select data-automation-id="timeselection-mode-secondary">
<option *ngFor="let mode of modes">
Previous {{ mode }}
</option>
</select>
No reactive forms are involved, just plain HTML tags.
mycalendar.component.ts
modes=['Year', 'Quarter', 'Sprint'];
Could someone guide me on how to generate automation ids at runtime or if I am approaching this issue incorrectly? I appreciate any alternative suggestions.