2020-11-25 02:26:00 +00:00
|
|
|
import findAsync from './find-async';
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
const findDropdownItemWithText = async (parent, text) => {
|
2020-11-25 02:26:00 +00:00
|
|
|
let item;
|
2021-03-03 20:00:56 +00:00
|
|
|
await parent.waitUntil(async () => {
|
2021-05-12 06:35:00 +00:00
|
|
|
const items = await parent.react$$('DropdownItem');
|
2020-11-25 02:26:00 +00:00
|
|
|
item = await findAsync(items, async i => (await i.getText()) === text);
|
|
|
|
return !!item;
|
|
|
|
});
|
2021-03-03 20:00:56 +00:00
|
|
|
return item;
|
|
|
|
};
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
export const clickDropdownItemByText = async (parent, text) => {
|
|
|
|
const item = await findDropdownItemWithText(parent, text);
|
2020-11-25 02:26:00 +00:00
|
|
|
await item.waitForDisplayed();
|
|
|
|
await item.click();
|
|
|
|
};
|
2020-12-04 21:47:04 +00:00
|
|
|
|
|
|
|
export const clickOpenDropdownItemByText = async (app, text) => {
|
|
|
|
const item = await app.client
|
|
|
|
.$('.dropdown__menu[aria-hidden=false]')
|
|
|
|
.then(e => e.$(`button*=${text}`));
|
|
|
|
await item.waitForDisplayed();
|
|
|
|
await item.click();
|
|
|
|
};
|