I have a p-dropdown
:
HTML:
<span>
<p-dropdown formControlName="theatreGroup" [options]="theatreGroupsList">
</p-dropdown>
</span>
TS:
theatreGroupsList: any[] = [
{ label: 'Hamlet', value: 100 },
{ label: 'Dutchman', value: 351 },
{ label: 'King Lear', value: 180 },
{ label: 'Candida', value: 211 },
{ label: 'Twelfth Night', value: 133 }
];
I need to be able to get the theatreGroupsList and select an item. I can do this by checking the value of items in the array:
cy.get('p-dropdown[formControlName="theatreGroup"]').click().contains('Candida').click();
But the problem is theatreGroupsList is dynamic. Therefore, I need to be able to retrieve the list at any time and access its elements using index (i.e. not value or label). Can you help me with this?