Stabilize global command selection

This commit is contained in:
Vsevolod Kukol
2026-09-11 23:35:56 +02:00
parent b16229d1f8
commit 3a1f5143c7
+11 -6
View File
@@ -497,13 +497,18 @@ export class DataExplorer {
return new DocumentsTab(this.frame, tabId, tab, documentsTab); return new DocumentsTab(this.frame, tabId, tab, documentsTab);
} }
/** Select the primary global command button. /** Select a global command from either the primary button or the overflow menu. */
*
* There's only a single "primary" button, but we still require you to pass the label to confirm you're selecting the right button.
*/
async globalCommandButton(label: string): Promise<Locator> { async globalCommandButton(label: string): Promise<Locator> {
await this.frame.getByTestId("GlobalCommands").click(); const globalCommands = this.frame.getByTestId("GlobalCommands");
return this.frame.getByRole("menuitem", { name: label }); const primaryButton = globalCommands.getByRole("button", { name: label, exact: true });
if (await primaryButton.isVisible()) {
return primaryButton;
}
await globalCommands.locator('button[aria-haspopup="menu"]:visible').click();
const menuItem = this.frame.getByRole("menuitem", { name: label, exact: true });
await menuItem.waitFor();
return menuItem;
} }
/** Select the command bar button with the specified label */ /** Select the command bar button with the specified label */