diff --git a/test/functional/apps/dashboard/dashboard_snapshots.js b/test/functional/apps/dashboard/dashboard_snapshots.js index e98c4afc443f8..698f4d1de6d57 100644 --- a/test/functional/apps/dashboard/dashboard_snapshots.js +++ b/test/functional/apps/dashboard/dashboard_snapshots.js @@ -53,7 +53,6 @@ export default function ({ getService, getPageObjects, updateBaselines }) { await PageObjects.common.closeToast(); await PageObjects.dashboard.saveDashboard('tsvb'); - await PageObjects.common.closeToast(); await PageObjects.dashboard.clickFullScreenMode(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickExpandPanelToggle(); @@ -74,7 +73,6 @@ export default function ({ getService, getPageObjects, updateBaselines }) { await PageObjects.common.closeToast(); await PageObjects.dashboard.saveDashboard('area'); - await PageObjects.common.closeToast(); await PageObjects.dashboard.clickFullScreenMode(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickExpandPanelToggle(); diff --git a/test/functional/page_objects/dashboard_page.js b/test/functional/page_objects/dashboard_page.js index af3a15e9b3015..2460422722835 100644 --- a/test/functional/page_objects/dashboard_page.js +++ b/test/functional/page_objects/dashboard_page.js @@ -305,7 +305,8 @@ export function DashboardPageProvider({ getService, getPageObjects }) { /** * Save the current dashboard with the specified name and options and - * verify that the save was successful + * verify that the save was successful, close the toast and return the + * toast message * * @param dashName {String} * @param saveOptions {{storeTimeWithDashboard: boolean, saveAsNew: boolean, needsConfirm: false, waitDialogIsClosed: boolean }} @@ -319,8 +320,11 @@ export function DashboardPageProvider({ getService, getPageObjects }) { // Confirm that the Dashboard has actually been saved await testSubjects.existOrFail('saveDashboardSuccess'); + const message = await PageObjects.common.closeToast(); await PageObjects.header.waitUntilLoadingHasFinished(); await this.waitForSaveModalToClose(); + + return message; } async waitForSaveModalToClose() { diff --git a/test/functional/services/find.ts b/test/functional/services/find.ts index c65821ea73ace..312668b718dc0 100644 --- a/test/functional/services/find.ts +++ b/test/functional/services/find.ts @@ -303,10 +303,22 @@ export async function FindProvider({ getService }: FtrProviderContext) { timeout: number = WAIT_FOR_EXISTS_TIME ): Promise { log.debug(`Find.existsByDisplayedByCssSelector('${selector}') with timeout=${timeout}`); - return await this.exists(async drive => { - const elements = wrapAll(await drive.findElements(By.css(selector))); - return await this.filterElementIsDisplayed(elements); - }, timeout); + try { + await retry.tryForTime(timeout, async () => { + // make sure that the find timeout is not longer than the retry timeout + await this._withTimeout(Math.min(timeout, WAIT_FOR_EXISTS_TIME)); + const elements = await driver.findElements(By.css(selector)); + await this._withTimeout(defaultFindTimeout); + const displayed = await this.filterElementIsDisplayed(wrapAll(elements)); + if (displayed.length === 0) { + throw new Error(`${selector} is not displayed`); + } + }); + } catch (err) { + await this._withTimeout(defaultFindTimeout); + return false; + } + return true; } public async existsByCssSelector(