Skip to content

Commit 7b30bdb

Browse files
committed
fix(e2e): update select option helper to be able to handle combobox
1 parent 29f37a6 commit 7b30bdb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/compass-e2e-tests/helpers/commands/select-option.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ export async function selectOption(
88
optionText: string
99
): Promise<void> {
1010
// click the field's button
11-
const selectButton = browser.$(selector);
11+
const selectButton = browser.$(`${selector}`);
1212
await selectButton.waitForDisplayed();
1313
await selectButton.click();
1414

15-
const controlledMenuId: string = await selectButton.getAttribute(
16-
'aria-controls'
17-
);
15+
let controlledMenuId = await selectButton.getAttribute('aria-controls');
16+
// In leafygreen combobox we usually not immediately targeting the element
17+
// that controls the listbox, so if we haven't find it, try to look in the
18+
// element we selected
19+
if (!controlledMenuId) {
20+
controlledMenuId = await selectButton
21+
.$('[aria-controls]')
22+
.getAttribute('aria-controls');
23+
}
1824
// wait for the list to pop up
1925
const selectList = browser.$(`[id="${controlledMenuId}"][role="listbox"]`);
2026
await selectList.waitForDisplayed();

0 commit comments

Comments
 (0)