From 5bc5c03ab8f9c43e1d26b89db968cc6306c338ea Mon Sep 17 00:00:00 2001 From: Stacey Gammon Date: Wed, 31 May 2017 12:29:08 -0400 Subject: [PATCH] fix dashboard view/edit flaky test (#12026) * attempt to fix dashboard view/edit flaky test hope to fix https://github.com/elastic/kibana/issues/12014 * Need to wait for global loading indicator to be hidden once top nav is visible * use Error object for throw * inline function only used once --- test/functional/page_objects/common_page.js | 9 +++++++++ test/functional/page_objects/header_page.js | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/functional/page_objects/common_page.js b/test/functional/page_objects/common_page.js index fdf7760556cd..cbc8be50cc46 100644 --- a/test/functional/page_objects/common_page.js +++ b/test/functional/page_objects/common_page.js @@ -270,6 +270,15 @@ export function CommonPageProvider({ getService, getPageObjects, getPageObject } async isChromeVisible() { return await testSubjects.exists('kibanaChrome'); } + + async waitForTopNavToBeVisible() { + await retry.try(async () => { + const isNavVisible = await testSubjects.exists('top-nav'); + if (!isNavVisible) { + throw new Error('Local nav not visible yet'); + } + }); + } } return new CommonPage(); diff --git a/test/functional/page_objects/header_page.js b/test/functional/page_objects/header_page.js index b39c420527ed..97201a491688 100644 --- a/test/functional/page_objects/header_page.js +++ b/test/functional/page_objects/header_page.js @@ -10,6 +10,7 @@ export function HeaderPageProvider({ getService, getPageObjects }) { const defaultFindTimeout = config.get('timeouts.find'); class HeaderPage { + async clickSelector(selector) { remote.setFindTimeout(defaultFindTimeout); await remote.findByCssSelector(selector).click(); @@ -18,19 +19,22 @@ export function HeaderPageProvider({ getService, getPageObjects }) { async clickDiscover() { log.debug('click Discover tab'); await this.clickSelector('a[href*=\'discover\']'); - await PageObjects.common.sleep(3000); + await PageObjects.common.waitForTopNavToBeVisible(); + await this.isGlobalLoadingIndicatorHidden(); } async clickVisualize() { log.debug('click Visualize tab'); await this.clickSelector('a[href*=\'visualize\']'); - await PageObjects.common.sleep(3000); + await PageObjects.common.waitForTopNavToBeVisible(); + await this.isGlobalLoadingIndicatorHidden(); } async clickDashboard() { log.debug('click Dashboard tab'); await this.clickSelector('a[href*=\'dashboard\']'); - await PageObjects.common.sleep(3000); + await PageObjects.common.waitForTopNavToBeVisible(); + await this.isGlobalLoadingIndicatorHidden(); } async clickSettings() {