I've looked online for this but I could only find solutions for basic dropdowns. My dropdown looks like this:
<p-dropdown [options]="uyrukList"
id="uyruk" name="uyruk"
#uyrukInput="ngModel" [required]="true"
[autoDisplayFirst]="false" [(ngModel)]="uyruk" optionLabel="ad">
</p-dropdown>
I've tried this:
const select = element(by.id('uyruk'));
select.$('value=myRandomItem').click();
but it didn't work.
Is there a way I can select any items in this dropdown menu using protractor? It does not matter to me which item it is.
CodePudding user response:
I've tried to access my dropdown elements using their tagName and it worked for me.
element.all(by.id('uyruk')).click();
browser.sleep(500);
const list = element.all(by.tagName('p-dropdownitem'));
list.first().click();
In order to access any element with its index:
list.get(index).click();
CodePudding user response:
to select an item in a dropdown menu you can try to see the id of the dropdown when it renders on the app using your console, then watch the id of an item also. With protractor just click to the id of the dropdown then the id of the item. If the items do not have ids then try to add them manually.