diff --git a/packages/compass-e2e-tests/helpers/commands/connect.ts b/packages/compass-e2e-tests/helpers/commands/connect.ts index 7216a941e5b..60fbc9d6d2d 100644 --- a/packages/compass-e2e-tests/helpers/commands/connect.ts +++ b/packages/compass-e2e-tests/helpers/commands/connect.ts @@ -187,8 +187,21 @@ export async function connectByName( connectionName: string, options: ConnectionResultOptions = {} ) { + // make sure the connection shows up before we try and hover over it + await browser + .$(Selectors.sidebarConnection(connectionName)) + .waitForDisplayed(); + + // focus the filter input so that we can be sure the window is focused and the + // mouse pointer is away from the connection itself + await browser.clickVisible(Selectors.SidebarFilterInput); + + // hover over the connection and hope the connect button shows up await browser.hover(Selectors.sidebarConnection(connectionName)); + + // hopefully the connect button showed up on hover and we can click it await browser.clickVisible(Selectors.sidebarConnectionButton(connectionName)); + await browser.waitForConnectionResult(connectionName, options); }