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() {